网页SEO代码规范

371 阅读2分钟

网址URL

  • 使用https协议
    • google推荐使用更安全的https协议。
    • http协议301https协议;这种方式会短时影响流量,不过会慢慢恢复。最好还是直接更改调用点为https。
  • 使用规范的http状态码
    • 推荐使用200301404等规范状态码,避免使用自定义状态码,不便于蜘蛛理解。
  • 保持简单的url结构
  • 应以.html结尾
  • 避免使用相对地址。
    • google不推荐页面中使用相对地址,最好都是绝对地址。
  • 做好网址映射。
    • 使用alternate标签适配。

      <link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.haodf.com/hospital/1.html">
      
    • 当出现多个url指向同一页面时,使用canonical标签,解决内容重复的收录,导致被降权等问题。

      // 两种情况需要使用 canonical 标签
      // 1.网站进行了改版,将旧的内容搬到了新的URL链接上,但是没有做301重定向。
      // 2.一种是动态页面,一种是伪静态页面,但是内容都是一样的。
      
      // 使用
      <link rel=”canonical”href=”你的网页权威链接”/>
      // 示例
      <link rel="canonical" href="<https://www.haodf.com/>">
      
  • 避免过多使用重定向。
    • google推荐3个以内的为最佳,最多不超过5个。
    • 但实际效果是最好一个都不要有。

网页语义化标签规范

  • 网页DOCTYPE声明
  • 页面head部分
    • 页面head主要包括页面编码、TDK、一系列meta适配标签、css、script标签
  • 页面语义化标签结构
  • jsonld数据
    • jsonld数据能够大大的帮助蜘蛛更好的理解页面结构和页面内容。有面包屑的页面,都需要添加面包屑的jsonld

      <!-- jsonld数据 -->
      <!-- 面包屑jsonld数据 -->
      <script type="application/ld+json">
        {
          "@context": "https://schema.org",
          "@type": "BreadcrumbList",
          "itemListElement": [{
            "@type": "ListItem",
            "position": 1,
            "name": "Books",
            "item": "https://example.com/books"
          },{
            "@type": "ListItem",
            "position": 2,
            "name": "Science Fiction",
            "item": "https://example.com/books/sciencefiction"
          },{
            "@type": "ListItem",
            "position": 3,
            "name": "Award Winners"
          }]
        }
      </script>
      <!-- 医生个人信息jsonld数据 -->
      <script type="application/ld+json">
        {
          "@context": "http://schema.org",
          "@type": "Person",
          "name": "ma lei",
          "disambiguatingDescription": "41st President of the United States",
          "children": {
            "@type": "Person",
            "name": "George W. Bush",
            "disambiguatingDescription": "43rd President of the United States"
          }
        }
      </script>
      <!-- /jsonld数据 -->