sitemap 多入口管理
我项目中有多个 sitemap,如何有一个统一的入口?
sitemap1.xml
sitemap2.xml
sitemap3.xml
sitemap1.xml
sitemap2.xml
sitemap3.xml
你可以使用 Sitemap Index 来统一管理多个 sitemap 文件。创建一个 sitemap_index.xml
,并在其中列出所有 sitemap 文件,例如:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap1.xml</loc>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap2.xml</loc>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap3.xml</loc>
</sitemap>
</sitemapindex>
步骤
- 确保
sitemap_index.xml
能通过 Web 服务器访问。 - 在
robots.txt
中添加Sitemap
指向sitemap_index.xml
:Sitemap: https://example.com/sitemap_index.xml
- 在 Google Search Console 提交
sitemap_index.xml
,它会自动解析并处理所有子 sitemap。
这样,你的多个 sitemap.xml
就有了一个统一的入口,方便搜索引擎爬取和管理。