使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如何结合使用站点地图扩展
站点地图扩展是将您在网站上使用的各类内容及其元数据告知 Google 的绝佳方式。您网页上的内容通常适合多种扩展;例如,您可能会发布嵌入图片和视频的新闻报道。此外,您的网页还可能会进行本地化,这可能意味着您可以为本地化网页添加 hreflang
注释。
命名空间
对于您要在站点地图中使用的每个站点地图扩展,您需要指定相应命名空间来声明扩展支持的标记。您可以借助 urlset
标记的 xmlns
属性来完成该步骤。Google 支持的站点地图扩展的命名空间包括:
声明多个命名空间
如需声明多个命名空间,请按照对应扩展的文档中的说明,将相应的命名空间引用添加到您的站点地图中。以下示例演示了如何向站点地图添加新闻、视频和 xhtml(适用于 hreflang
)扩展:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<!-- rest of the sitemap -->
结合使用站点地图扩展
声明完命名空间后,请遵循您要使用的相应站点地图扩展的文档中的实现详情。
如需结合使用扩展,请按照各站点地图扩展的文档中的说明,将所使用的站点地图扩展中的标记逐一添加到相应的 <url>
标记中。
例如,要向站点地图添加新闻、视频和 xhtml (hreflang
) 扩展,请按以下步骤操作:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://www.example.com/english/page.html</loc>
<!-- Starting with the news extension tags -->
<news:news>
<news:publication>
<news:name>The Example Times</news:name>
<news:language>en</news:language>
</news:publication>
<news:publication_date>2008-12-23</news:publication_date>
<news:title>Companies A, B in Merger Talks</news:title>
</news:news>
<!-- Next we add video extension tags -->
<video:video>
<video:thumbnail_loc>https://www.example.com/thumbs/123.jpg</video:thumbnail_loc>
<video:title>Lizzi is painting the wall</video:title>
<video:description>
Gary is watching the paint dry on the wall Lizzi painted.
</video:description>
<video:player_loc>
https://player.example.com/video/987654321
</video:player_loc>
</video:video>
<!-- And finally the xhtml tags for hreflang -->
<xhtml:link
rel="alternate"
hreflang="de"
href="https://www.example.de/deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="https://www.example.de/schweiz-deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://www.example.com/english/page.html"/>
</url>
<!-- Add more <url> tags -->
站点地图中扩展的顺序在 <loc>
标记之后并不相关。请遵循站点地图常规最佳实践,尤其是注意文件大小限制。组合使用站点地图扩展会大幅增加站点地图的文件大小。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-04。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[[["\u003cp\u003eSitemap extensions inform Google about diverse content types and metadata on your site, such as images, videos, news, and localized versions.\u003c/p\u003e\n"],["\u003cp\u003eTo use sitemap extensions, declare their respective namespaces within the \u003ccode\u003eurlset\u003c/code\u003e tag of your sitemap file.\u003c/p\u003e\n"],["\u003cp\u003eCombine extensions by adding tags from different extensions within the \u003ccode\u003e<url>\u003c/code\u003e tag, following each extension's documentation.\u003c/p\u003e\n"],["\u003cp\u003eThe order of extension tags within the \u003ccode\u003e<url>\u003c/code\u003e tag (after the \u003ccode\u003e<loc>\u003c/code\u003e tag) does not matter.\u003c/p\u003e\n"],["\u003cp\u003eBe mindful of sitemap file size limits, as combining extensions can significantly increase file size.\u003c/p\u003e\n"]]],["Sitemap extensions allow specifying content types and metadata. To combine extensions, declare each extension's namespace using the `xmlns` attribute within the `\u003curlset\u003e` tag, referencing the correct URLs for image, news, video, or `xhtml` (for `hreflang`). After declaring namespaces, insert the tags from each desired extension, following the specifications in the respective documentation, within the `\u003curl\u003e` tag. Extensions can be added in any order after the `\u003cloc\u003e` tag, and combining extensions will increase the overall sitemap file size.\n"],null,["# How to Combine Sitemap Extensions | Google Search Central\n\nHow to combine sitemap extensions\n=================================\n\n\nSitemap extensions are a great way to tell Google about the different kinds of content and\ntheir metadata that you're using on your site. Often the content on your pages may fit into\nmultiple kinds of extensions; for example, you might be publishing news articles that embed\nimages and videos. Additionally, your pages may be localized as well, which might mean that\nyou could add `hreflang` annotations for your localized pages.\n\nNamespaces\n----------\n\n\nFor each sitemap extension that you want to use in a sitemap you need to specify the\nrespective namespace that declares the tags the extension supports. This is done with the\n`xmlns` attribute of the `urlset` tag. The namespaces for the sitemap\nextensions Google supports are:\n\n| Extension tags and their namespace definitions ||\n|---------------------------|------------------------------------------------------------------------------------------------------|\n| `image:` | [`http://www.google.com/schemas/sitemap-image/1.1`](http://www.google.com/schemas/sitemap-image/1.1) |\n| `news:` | [`http://www.google.com/schemas/sitemap-news/0.9`](http://www.google.com/schemas/sitemap-news/0.9) |\n| `video:` | [`http://www.google.com/schemas/sitemap-video/1.1`](http://www.google.com/schemas/sitemap-video/1.1) |\n| `xhtml:` (for `hreflang`) | [`http://www.w3.org/1999/xhtml`](http://www.w3.org/1999/xhtml) |\n\n### Declaring multiple namespaces\n\n\nTo declare multiple namespaces, add the respective namespace references to your sitemap as\ndescribed in the documentation of the respective extensions. Here's an example that shows how\nto add the news, video, and xhtml (for `hreflang`) extensions to a sitemap: \n\n```text\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003curlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\n xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\n xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"\u003e\n \u003curl\u003e\n\u003c!-- rest of the sitemap --\u003e\n```\n\nCombining sitemap extensions\n----------------------------\n\n\nOnce you declared the namespaces, follow the implementation details from the respective sitemap\nextension documentation you're going to use.\n\n- [Image sitemap](/search/docs/crawling-indexing/sitemaps/image-sitemaps)\n- [News sitemap](/search/docs/crawling-indexing/sitemaps/news-sitemap)\n- [Video sitemap](/search/docs/crawling-indexing/sitemaps/video-sitemaps)\n- [`hreflang`](/search/docs/specialty/international/localized-versions#sitemap)\n\n\nTo combine extensions, add the tags from whatever sitemap extensions you're using, one after the\nother, to the appropriate `\u003curl\u003e` tag, as described in each sitemap extension's\ndocumentation.\n\n\nFor example, to add news, video, and xhtml (`hreflang`) extensions to a sitemap: \n\n```scdoc\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003curlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\n xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\n xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"\u003e\n \u003curl\u003e\n \u003cloc\u003ehttps://www.example.com/english/page.html\u003c/loc\u003e\n \u003c!-- Starting with the news extension tags --\u003e\n \u003cnews:news\u003e\n \u003cnews:publication\u003e\n \u003cnews:name\u003eThe Example Times\u003c/news:name\u003e\n \u003cnews:language\u003een\u003c/news:language\u003e\n \u003c/news:publication\u003e\n \u003cnews:publication_date\u003e2008-12-23\u003c/news:publication_date\u003e\n \u003cnews:title\u003eCompanies A, B in Merger Talks\u003c/news:title\u003e\n \u003c/news:news\u003e\n \u003c!-- Next we add video extension tags --\u003e\n \u003cvideo:video\u003e\n \u003cvideo:thumbnail_loc\u003ehttps://www.example.com/thumbs/123.jpg\u003c/video:thumbnail_loc\u003e\n \u003cvideo:title\u003eLizzi is painting the wall\u003c/video:title\u003e\n \u003cvideo:description\u003e\n Gary is watching the paint dry on the wall Lizzi painted.\n \u003c/video:description\u003e\n \u003cvideo:player_loc\u003e\n https://player.example.com/video/987654321\n \u003c/video:player_loc\u003e\n \u003c/video:video\u003e\n \u003c!-- And finally the xhtml tags for hreflang --\u003e\n \u003cxhtml:link\n rel=\"alternate\"\n hreflang=\"de\"\n href=\"https://www.example.de/deutsch/page.html\"/\u003e\n \u003cxhtml:link\n rel=\"alternate\"\n hreflang=\"de-ch\"\n href=\"https://www.example.de/schweiz-deutsch/page.html\"/\u003e\n \u003cxhtml:link\n rel=\"alternate\"\n hreflang=\"en\"\n href=\"https://www.example.com/english/page.html\"/\u003e\n \u003c/url\u003e\n\u003c!-- Add more \u003curl\u003e tags --\u003e\n```\n\n\nThe order of the extension in the sitemap is irrelevant after the `\u003cloc\u003e`\ntag. Keep in mind the\n[general sitemap best practices](/search/docs/crawling-indexing/sitemaps/build-sitemap#general-guidelines),\nespecially the file size limits. Combining sitemap extensions increases the file size of your\nsitemap significantly."]]