抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

网站地图介绍

在网站地图的 sitemap 文件中,您可以在其中提供与您网站中的网页、视频或其他文件有关的信息,还可以说明这些内容之间的关系。Google 等搜索引擎会读取此文件,以便更加智能地抓取您的网站。站点地图会告诉 Google 您认为网站中的哪些网页和文件比较重要,还会提供与这些文件有关的重要信息。

以网页为例,这些信息包括:

  • 网页上次更新的时间
  • 网页更改的频率
  • 网页是否有其他语言版本

等等。

sitemap 文件说明

sitemap格式

网站地图可以是 XML、RSS、纯文本等格式,下面是一个 XML 格式的网站地图。

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>http://www.zerow.cn/</loc>
      <lastmod>2005-01-01</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>
</urlset> 
  1. XML 文档声明,就是第一行的 XML 声明。
  2. 声明协议标准,第二行 xmlns 里面的内容。
  3. <urlset> 开头,</urlset>结尾。
  4. 每一个 URL 被包含在 url 闭合标签中。
  5. 每个 sitemap 文件中的 URL 数量不能超过 50000 个。
  6. 每个站点地图未压缩文件不超过 50MB 大小。

标签说明

节点是否必须表述
urlset站点地图根元素。
url父节点
loc链接网址,以协议(比如http)开头,并以/结尾,字符小于2048个。
lastmodW3C Datetime编码格式标准,也可以使用YYYY-MM-DD格式,表示上次修改时间。
changefreq告知搜索引擎页面内容改变的间隔(实际时间间隔由搜索引擎决定)。
priority页面在网站中的优先程度,值为0.01.0之间。
未设置时默认为0.5
该值只影响本站点的页面,并不会影响搜索引擎展示结果中的位置。

changefreq 值类型:

  • always
  • hourly
  • daily
  • weekly
  • monthly
  • yearly
  • never

always表示每次访问该页面时内容都会改变,而never表示归档内容。

Google 会忽略 <priority><changefreq> 值。

转移字符

字符符号转义码
& 符号&&
单引号''
双引号""
大于号>>
小于号<<
  • 地图文件使用 UTF-8 编码
  • 网址需要经过转义

多语言站点地图

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
    http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
    http://www.w3.org/1999/xhtml
    http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">
    <url>
        <loc>https://www.zerow.cn/article/12128267.html</loc>
        <lastmod>2005-01-01</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.8</priority>
        <xhtml:link rel="alternate" hreflang="en-US" href="https://www.zerow.cn/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="zh-Hans" href="https://www.zerow.cn/zh/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="fr-FR" href="https://www.zerow.cn/fr/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="de-DE" href="https://www.zerow.cn/de/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="it-IT" href="https://www.zerow.cn/it/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="es-ES" href="https://www.zerow.cn/es/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="pt-PT" href="https://www.zerow.cn/pt/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="pt-BR" href="https://www.zerow.cn/br/article/12128267.html"/>
        <xhtml:link rel="alternate" hreflang="en" href="https://www.zerow.cn/article/12128267.html"/>
    </url>
<url>

使用索引

如果站点地图较多的话可以将文件拆开,并且使用索引文件将拆分的文件进行关联。索引文件生成要求同 sitemap 文件。

  1. 生成 sitemap.xml 文件

    <?xml version="1.0" encoding="UTF-8"?>
    <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
    <loc>https://www.zerow.cn/sitemap-articles-1.xml</loc>
    <lastmod>2005-01-01</lastmod>
    </sitemap>
    <sitemap>
    <loc>https://www.zerow.cn/sitemap-articles-2.xml</loc>
    <lastmod>2005-01-01</lastmod>
    </sitemap>
    <sitemap>
    <loc>https://www.zerow.cn/sitemap-articles-3.xml</loc>
    <lastmod>2005-01-01</lastmod>
    </sitemap>
    </sitemapindex>
  2. 生成其中一个拆分文件:https://www.zerow.cn/sitemap-articles-1.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
       <url>
          <loc>https://www.zerow.cn/article/12128267.html/</loc>
          <lastmod>2005-01-01</lastmod>
          <changefreq>monthly</changefreq>
          <priority>0.8</priority>
       </url>
       <url>
          <loc>https://www.zerow.cn/article/12128268.html/</loc>
          <lastmod>2005-01-01</lastmod>
          <changefreq>monthly</changefreq>
          <priority>0.8</priority>
       </url>
    </urlset> 

sitemap 文件压缩

sitemap 文件支持 gzip 压缩

<?xml version="1.0" encoding="UTF-8"?>
  <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
      <loc>https://www.zerow.cn/sitemap-articles-1.xml.gz</loc>
    </sitemap>
    <sitemap>
      <loc>https://www.zerow.cn/sitemap-articles-2.xml.gz</loc>
    </sitemap>
  </sitemapindex>

使用 gzip 压缩可以加快网络传输速度,提高抓取效率。

提交站点地图

Google Search Control:https://search.google.com/u/4/search-console/sitemaps

评论