技术 SEO

Sitemap、robots、canonical、hreflang、Schema——让搜索引擎顺畅抓取和收录你的所有页面。

一句话结论

把 Sitemap 提交给 Google Search Console,放好 robots.txt,用 canonical 标签防重复内容。如果网站有多语言,加上 hreflang。选做一个 Schema 标记。这些配好了就不用再动。

怎么做

Sitemap

创建 sitemap.xml,列出网站上所有重要页面,提交给 Google Search Console。

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>https://example.com/page1</loc>
      <lastmod>2024-01-01</lastmod>
   </url>
</urlset>

收录检查

在 Google Search Console 用"网址检查"工具看你的页面是否已被收录。没收录的页面,搜不到。

Robots.txt

放在根目录,告诉爬虫哪些目录不要访问。

User-agent: *
Disallow: /admin/
Sitemap: https://example.com/sitemap.xml

Canonical 标签

内容相似的页面用 canonical 标签指定"官方版本",防止权重分散。

<link rel="canonical" href="https://example.com/product" />

Hreflang(多语言)

多语言网站用 hreflang 告诉 Google 各语言版本的关系。

<link rel="alternate" hreflang="zh-cn" href="https://example.com/zh/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Schema 结构化数据

用 Schema 标记告诉 Google 你页面的内容类型(FAQ、产品、文章等),有机会在搜索结果中显示更丰富的样式。

{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [{
    "@type": "Question",
    "name": "SEO 需要多久见效?",
    "acceptedAnswer": {
      "@type": "Answer",
      "text": "通常需要数周到数月。"
    }
  }]
}

工具

延伸阅读

完整版教程:SimpleSEO · 其他优化