xml-sitemap by kostja94/marketing-skills
npx skills add https://github.com/kostja94/marketing-skills --skill xml-sitemap指导站点地图的创建、审核和优化,以便搜索引擎发现。
调用时机:在首次使用时,如果合适,先用 1-2 句话说明此技能涵盖的内容及其重要性,然后提供主要输出。在后续使用或用要求跳过时,直接进入主要输出。
根据项目的页面列表生成符合 sitemaps.org 协议的 XML 站点地图,并在 robots.txt 中声明它。
首先检查项目上下文:如果存在 .claude/project-context.md 或 .cursor/project-context.md,请读取它以获取网站 URL 和页面结构。
识别:
https://example.com)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 项目 | 规范 |
|---|
| 单个站点地图限制 | 50,000 个 URL,50MB(未压缩) |
| 站点地图索引 | 当超过限制时,进行分割,并由主索引引用子站点地图 |
| 编码 | UTF-8 |
| URL 格式 | 完整 URL,相同主机,包含 https:// |
| 必需标签 | <loc> |
| 可选标签 | <lastmod>、<changefreq>、<priority> |
| 字段 | 描述 | 推荐 |
|---|---|---|
| url | 完整 URL | https://example.com/path |
| lastModified | 页面最后修改时间 | 使用页面元数据,ISO 8601;无数据时使用 YYYY-MM-DD 或省略 |
| changeFrequency | 更新频率 | 首页 daily,列表页 weekly,内容页 monthly |
| priority | 相对重要性 | 首页 1.0,聚合页面 0.9,内容页面 0.7–0.8,其他 0.5–0.6 |
YYYY-MM-DD 或 YYYY-MM-DDTHH:MM:SS+TZD),例如 2025-01-15,2025-01-15T14:30:00+08:00。new Date() 作为 lastmod——这会导致所有 URL 共享相同的时间戳;搜索引擎可能会忽略。always、hourly、daily、weekly、monthly、yearly、never。/sitemap.xml。/sitemap/posts.xml、/sitemap/pages.xml、/sitemap/zh.xml、/sitemap/en.xml。/sitemap.xml 或 /sitemap-index.xml,每个条目为 <sitemap><loc>...</loc></sitemap>。/sitemap/zh.xml、/sitemap/en.xml。/sitemap/zh-posts.xml、/sitemap/en-posts.xml。对于多语言网站,在每个 <url> 条目内添加 xhtml:link hreflang 替代链接。推荐用于大型网站(100+ 多语言页面);集中管理 hreflang。
规则:
x-default。xmlns:xhtml="http://www.w3.org/1999/xhtml" 命名空间。<loc> 通常使用默认语言区域(简洁)的 URL;x-default 也指向该 URL。<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/page</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/page" />
<xhtml:link rel="alternate" hreflang="zh" href="https://example.com/zh/page" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/page" />
</url>
</urlset>
在站点地图索引中列出所有语言站点地图;在 robots.txt 中包含。
| 技术栈 | 实现方式 |
|---|---|
| Next.js App Router | app/sitemap.ts 导出 MetadataRoute.Sitemap 或 generateSitemaps |
| Next.js Pages Router | pages/sitemap.xml.ts 或 getServerSideProps 返回 XML |
| Astro | src/pages/sitemap-index.xml.ts 或 @astrojs/sitemap |
| Vite / 静态构建 | 构建脚本生成 public/sitemap.xml |
| 其他 | 生成静态 /sitemap.xml 或通过 API 动态返回 |
'/((?!api|_next|sitemap|sitemap-index|.*\\..*).*)'。//zh、/en)/api/*、/admin/*、/_next/*创建一个配置(例如,site-pages-config.ts),导出:
modifiedDate,用于准确的 lastmodgetAllPageUrls(baseUrl),用于站点地图和 IndexNow原因:站点地图、IndexNow 和 feed 都可以从同一配置导入——无需重复维护 URL 列表。IndexNow 应使用相同的 URL 列表;避免使用单独的硬编码列表。
添加到 robots.txt:
Sitemap: https://example.com/sitemap.xml
如果有多个站点地图,仅声明主索引。
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2025-01-15</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/page</loc>
<lastmod>2025-01-10</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap/pages.xml</loc>
<lastmod>2025-01-15</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap/posts.xml</loc>
<lastmod>2025-01-14</lastmod>
</sitemap>
</sitemapindex>
| 问题 | 原因 / 修复方法 |
|---|---|
| 站点地图 404 | 构建失败、路径错误、导出不正确;检查路由和部署 |
| 页面缺失 | URL 不在数据源中、被过滤或排除 |
| lastmod 异常 | 避免 new Date();使用页面元数据中的 modifiedDate |
| Google 未索引 | 在 GSC 中提交站点地图;检查 Coverage (google-search-console) 和 robots |
| EN/ZH URL 不匹配 | 使用统一的数据源;按语言区域生成时共享相同的列表 |
每周安装次数
197
代码仓库
GitHub 星标数
237
首次出现
Mar 1, 2026
安全审计
安装于
kimi-cli181
cursor181
gemini-cli180
codex180
github-copilot180
opencode180
Guides sitemap creation, auditing, and optimization for search engine discovery.
When invoking : On first use , if helpful, open with 1–2 sentences on what this skill covers and why it matters, then provide the main output. On subsequent use or when the user asks to skip, go directly to the main output.
Generate an XML Sitemap that complies with the sitemaps.org protocol from the project's page list, and declare it in robots.txt.
Check for project context first: If .claude/project-context.md or .cursor/project-context.md exists, read it for site URL and page structure.
Identify:
https://example.com)| Item | Spec |
|---|---|
| Single sitemap limit | 50,000 URLs, 50MB (uncompressed) |
| Sitemap index | When exceeding limit, split and have main index reference sub-sitemaps |
| Encoding | UTF-8 |
| URL format | Full URL, same host, include https:// |
| Required tags | <loc> |
| Optional tags | <lastmod>, <changefreq>, <priority> |
| Field | Description | Recommendation |
|---|---|---|
| url | Full URL | https://example.com/path |
| lastModified | Page last modified time | Use page metadata, ISO 8601; use YYYY-MM-DD or omit when no data |
| changeFrequency | Update frequency | Home daily, list pages weekly, content pages monthly |
| priority | Relative importance | Home 1.0, aggregate pages 0.9, content pages 0.7–0.8, others 0.5–0.6 |
YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS+TZD), e.g. 2025-01-15, 2025-01-15T14:30:00+08:00.new Date() for lastmod—causes all URLs to share the same timestamp; search engines may ignore.always, hourly, daily, weekly, monthly, yearly, never./sitemap.xml directly./sitemap/posts.xml, /sitemap/pages.xml, /sitemap/zh.xml, /sitemap/en.xml./sitemap.xml or /sitemap-index.xml, each entry as <sitemap><loc>...</loc></sitemap>./sitemap/zh.xml, /sitemap/en.xml./sitemap/zh-posts.xml, /sitemap/en-posts.xml.For multilingual sites, add xhtml:link hreflang alternates inside each <url> entry. Recommended for large sites (100+ multilingual pages); centralizes hreflang management.
Rules :
Every language version must link to ALL others, including itself (self-reference).
Include x-default pointing to default locale.
Use xmlns:xhtml="http://www.w3.org/1999/xhtml" namespace.
<loc> typically uses default-locale (clean) URL; x-default points there too.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <url> <loc>https://example.com/page</loc> <xhtml:link rel="alternate" hreflang="en" href="https://example.com/page" /> <xhtml:link rel="alternate" hreflang="zh" href="https://example.com/zh/page" /> <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/page" /> </url> </urlset>
List all language sitemaps in sitemap index; include in robots.txt.
| Tech Stack | Implementation |
|---|---|
| Next.js App Router | app/sitemap.ts export MetadataRoute.Sitemap or generateSitemaps |
| Next.js Pages Router | pages/sitemap.xml.ts or getServerSideProps return XML |
| Astro | src/pages/sitemap-index.xml.ts or @astrojs/sitemap |
| Vite / Static build | Build script generates |
'/((?!api|_next|sitemap|sitemap-index|.*\\..*).*)'.//zh, /en)/api/*, /admin/*, /_next/*Create a config (e.g., site-pages-config.ts) that exports:
modifiedDate per page for accurate lastmodgetAllPageUrls(baseUrl) for sitemap and IndexNowWhy : Sitemap, IndexNow, and feed can all import from the same config—no duplicate URL maintenance. IndexNow should use the same URL list; avoid separate hardcoded lists.
Add to robots.txt:
Sitemap: https://example.com/sitemap.xml
With multiple sitemaps, only declare the main index.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2025-01-15</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/page</loc>
<lastmod>2025-01-10</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap/pages.xml</loc>
<lastmod>2025-01-15</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap/posts.xml</loc>
<lastmod>2025-01-14</lastmod>
</sitemap>
</sitemapindex>
| Issue | Cause / Fix |
|---|---|
| Sitemap 404 | Build failure, wrong path, incorrect export; check routes and deployment |
| Missing pages | URLs not in data source, filtered or excluded |
| lastmod anomaly | Avoid new Date(); use modifiedDate from page metadata |
| Google not indexing | Submit sitemap in GSC; check Coverage (google-search-console) and robots |
| EN/ZH URL mismatch | Use unified data source; share same list when generating by locale |
Weekly Installs
197
Repository
GitHub Stars
237
First Seen
Mar 1, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
kimi-cli181
cursor181
gemini-cli180
codex180
github-copilot180
opencode180
程序化SEO实战指南:大规模创建优质页面,避免内容单薄惩罚
35,800 周安装
public/sitemap.xml| Other | Generate static /sitemap.xml or return dynamically via API |