meta標籤整理

屬性 描述
http-equiv content-type / expire / refresh / set-cookie 把content屬性關聯到HTTP頭部。
name author / description / keywords / generator / revised / others 把 content 屬性關聯到一個名稱。
content some text 定義用於翻譯 content 屬性值的格式。

SEO優化

  • 頁面關鍵詞,每個網頁應具有描述該網頁內容的一組唯一的關鍵字。
    使用人們可能會搜索,並準確描述網頁上所提供信息的描述性和代表性關鍵字及短語。標記內容太短,則搜索引擎可能不會認爲這些內容相關。另外標記不應超過 874 個字符。
<meta name="keywords" content="your tags" />
  • 頁面描述,每個網頁都應有一個不超過 150 個字符且能準確反映網頁內容的描述標籤。
<meta name="description" content="150 words" />
  • 搜索引擎索引方式,robotterms是一組使用逗號(,)分割的值,通常有如下幾種取值:none,noindex,nofollow,all,index和follow。確保正確使用nofollow和noindex屬性值。
<meta name="robots" content="index,follow" />
<!--
    all:文件將被檢索,且頁面上的鏈接可以被查詢;
    none:文件將不被檢索,且頁面上的鏈接不可以被查詢;
    index:文件將被檢索;
    follow:頁面上的鏈接可以被查詢;
    noindex:文件將不被檢索;
    nofollow:頁面上的鏈接不可以被查詢。
 -->
  • 頁面重定向和刷新:content內的數字代表時間(秒),既多少時間後刷新。如果加url,則會重定向到指定網頁(搜索引擎能夠自動檢測,也很容易被引擎視作誤導而受到懲罰)。
<meta http-equiv="refresh" content="0;url=" />
  • 其他
<meta name="author" content="author name" /> <!-- 定義網頁作者 -->
<meta name="google" content="index,follow" />
<meta name="googlebot" content="index,follow" />
<meta name="verify" content="index,follow" />

網頁相關

  • 申明編碼
<meta charset='utf-8' />
  • 優先使用 IE 最新版本和 Chrome
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<!-- 關於X-UA-Compatible -->
<meta http-equiv="X-UA-Compatible" content="IE=6" ><!-- 使用IE6 -->
<meta http-equiv="X-UA-Compatible" content="IE=7" ><!-- 使用IE7 -->
<meta http-equiv="X-UA-Compatible" content="IE=8" ><!-- 使用IE8 -->
  • 瀏覽器內核控制:國內瀏覽器很多都是雙內核(webkit和Trident),webkit內核高速瀏覽,IE內核兼容網頁和舊版網站。而添加meta標籤的網站可以控制瀏覽器選擇何種內核渲染。參考文檔
 <meta name="renderer" content="webkit|ie-comp|ie-stand">
  • 禁止瀏覽器從本地計算機的緩存中訪問頁面內容:這樣設定,訪問者將無法脫機瀏覽。
<meta http-equiv="Pragma" content="no-cache">
  • 轉碼申明:用百度打開網頁可能會對其進行轉碼(比如貼廣告),避免轉碼可添加如下meta
<meta http-equiv="Cache-Control" content="no-siteapp" />

移動設備

  • viewport:能優化移動瀏覽器的顯示。如果不是響應式網站,不要使用initial-scale或者禁用縮放。
    大部分4.7-5寸設備的viewport寬設爲360px;5.5寸設備設爲400px;iphone6設爲375px;ipone6 plus設爲414px。
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
<!-- `width=device-width` 會導致 iPhone 5 添加到主屏後以 WebApp 全屏模式打開頁面時出現黑邊  -->


發佈了34 篇原創文章 · 獲贊 4 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章