一份关于任何可以写入到你的文档中 <head> 部分的清单。
最小推荐
下面是基本的、最低限度的网站基本标签:
- <meta charset="utf-8">
- <meta http-equiv="x-ua-compatible" content="ie=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!
- <title>页面标题</title>
网页元素
- <!
- <title>页面标题</title>
- <!
- <base href="https://example.com/page.html">
- <!
- <link rel="stylesheet" href="styles.css">
- <!
- <style>
- /* ... */
- </style>
- <!
- <script src="script.js"></script>
- <noscript><!
Meta 标签
- <!
- <meta charset="utf-8">
- <meta http-equiv="x-ua-compatible" content="ie=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!
- <!
- <meta http-equiv="Content-Security-Policy" content="default-src 'self'">
- <!
- <!
- <!
- <meta name="application-name" content="应用名称">
- <!
- <!
- <meta name="description" content="一个页面描述">
- <!
- <meta name="robots" content="index,follow"><!
- <meta name="googlebot" content="index,follow"><!
- <!
- <meta name="google" content="nositelinkssearchbox">
- <!
- <meta name="google" content="notranslate">
- <!
- <meta name="google-site-verification" content="verification_token">
- <!
- <meta name="yandex-verification" content="verification_token">
- <!
- <meta name="msvalidate.01" content="verification_token">
- <!
- <meta name="alexaVerifyID" content="verification_token">
- <!
- <meta name="p:domain_verify" content="code from pinterest">
- <!
- <meta name="norton-safeweb-site-verification" content="norton code">
- <!
- <meta name="generator" content="program">
- <!
- <meta name="subject" content="你的网站主题">
- <!
- <meta name="rating" content="General">
- <!
- <meta name="referrer" content="no-referrer">
- <!
- <meta name="format-detection" content="telephone=no">
- <!
- <meta http-equiv="x-dns-prefetch-control" content="off">
- <!
- <meta http-equiv="set-cookie" content="name=value; expires=date; path=url">
- <!
- <meta http-equiv="Window-Target" content="_value">
- <!
- <meta name="ICBM" content="latitude, longitude">
- <meta name="geo.position" content="latitude;longitude">
- <meta name="geo.region" content="country[-state]"><!
- <meta name="geo.placename" content="city/town"><!
链接
- <!
- <link rel="stylesheet" href="https://example.com/styles.css">
- <!
- <link rel="canonical" href="https://example.com/2010/06/9-things-to-do-before-entering-social-media.html">
- <!
- <link rel="shortlink" href="https://example.com/?p=42">
- <!
- <link rel="amphtml" href="https://example.com/path/to/amp-version.html">
- <!
- <link rel="manifest" href="manifest.json">
- <!
- <link rel="author" href="humans.txt">
- <!
- <link rel="license" href="copyright.html">
- <!
- <link rel="alternate" href="https://es.example.com/" hreflang="es">
- <!
- <link rel="me" href="https://google.com/profiles/thenextweb" type="text/html">
- <link rel="me" href="mailto:name@example.com">
- <link rel="me" href="sms:+15035550125">
- <!
- <link rel="archives" href="https://example.com/archives/">
- <!
- <link rel="index" href="https://example.com/">
- <!
- <link rel="self" type="application/atom+xml" href="https://example.com/atomFeed.php?page=3">
- <!
- <link rel="first" href="https://example.com/atomFeed.php">
- <link rel="next" href="https://example.com/atomFeed.php?page=4">
- <link rel="prev" href="https://example.com/atomFeed.php?page=2">
- <link rel="last" href="https://example.com/atomFeed.php?page=147">
- <!
- <link rel="EditURI" href="https://example.com/xmlrpc.php?rsd" type="application/rsd+xml" title="RSD">
- <!
- <link rel="pingback" href="https://example.com/xmlrpc.php">
- <!
- <link rel="webmention" href="https://example.com/webmention">
- <!
- <link rel="import" href="/path/to/component.html">
- <!
- <link rel="search" href="/open-search.xml" type="application/opensearchdescription+xml" title="Search Title">
- <!
- <link rel="alternate" href="https://feeds.feedburner.com/example" type="application/rss+xml" title="RSS">
- <link rel="alternate" href="https://example.com/feed.atom" type="application/atom+xml" title="Atom 0.3">
- <!
- <link rel="dns-prefetch" href="//example.com/">
- <link rel="preconnect" href="https://www.example.com/">
- <link rel="prefetch" href="https://www.example.com/">
- <link rel="prerender" href="https://example.com/">
- <link rel="preload" href="image.png" as="image">
- <!
网站图标
-
-
-
-
<link rel="icon" type="image/png" sizes="16x16" href="/path/to/favicon-16x16.png">
-
<link rel="icon" type="image/png" sizes="32x32" href="/path/to/favicon-32x32.png">
-
<link rel="icon" type="image/png" sizes="96x96" href="/path/to/favicon-96x96.png">
-
社交
Facebook Open Graph
- <meta property="fb:app_id" content="123456789">
- <meta property="og:url" content="https://example.com/page.html">
- <meta property="og:type" content="website">
- <meta property="og:title" content="Content Title">
- <meta property="og:image" content="https://example.com/image.jpg">
- <meta property="og:description" content="Description Here">
- <meta property="og:site_name" content="Site Name">
- <meta property="og:locale" content="en_US">
- <meta property="article:author" content="">
Facebook Instant Articles
- <meta charset="utf-8">
- <meta property="op:markup_version" content="v1.0">
- <!
- <link rel="canonical" href="http://example.com/article.html">
- <!
- <meta property="fb:article_style" content="myarticlestyle">
Twitter Cards
- <meta name="twitter:card" content="summary">
- <meta name="twitter:site" content="@site_account">
- <meta name="twitter:creator" content="@individual_account">
- <meta name="twitter:url" content="https://example.com/page.html">
- <meta name="twitter:title" content="Content Title">
- <meta name="twitter:description" content="Content description less than 200 characters">
- <meta name="twitter:image" content="https://example.com/image.jpg">
- Twitter 名片:入门指南
- Twitter 名片验证
Google+ / Schema.org
- <link href="https://plus.google.com/+YourPage" rel="publisher">
- <meta itemprop="name" content="内容标题">
- <meta itemprop="description" content="内容描述少于 200 个字符">
- <meta itemprop="image" content="https://example.com/image.jpg">
Pinterest
根据他们的帮助中心可知,Pinterest 允许你禁止他人保存你网站里的内容。description 为可选。
- <meta name="pinterest" content="nopin" description="Sorry, you can't save from my website!">
OEmbed
- <link rel="alternate" type="application/json+oembed"
- href="http://example.com/services/oembed?url=http%3A%2F%2Fexample.com%2Ffoo%2F&format=json"
- title="oEmbed Profile: JSON">
- <link rel="alternate" type="text/xml+oembed"
- href="http://example.com/services/oembed?url=http%3A%2F%2Fexample.com%2Ffoo%2F&format=xml"
- title="oEmbed Profile: XML">
浏览器 / 平台
Apple iOS
- <!
- <meta name="apple-itunes-app" content="app-id=APP_ID,affiliate-data=AFFILIATE_ID,app-argument=SOME_TEXT">
- <!
- <meta name="format-detection" content="telephone=no">
- <!
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <meta name="apple-mobile-web-app-title" content="应用标题">
- <!
- <!
- <link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png">
- <!
- <!
- <!
- <link rel="apple-touch-startup-image" href="path/to/startup.png">
- <!
- <meta name="apple-itunes-app" content="app-id=APP-ID, app-argument=http/url-sample.com">
- <link rel="alternate" href="ios-app://APP-ID/http/url-sample.com">
Apple Safari
- <!
- <link rel="mask-icon" href="path/to/icon.svg" color="red">
Google Android
- <meta name="theme-color" content="#E64545">
- <!
- <meta name="mobile-web-app-capable" content="yes">
- <!
Google Chrome
- <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/APP_ID">
- <!
- <meta name="google" content="notranslate">
Google Chrome Mobile (只针对 Android)
从 Chrome 31 开始,你可以设置你的 Web 应用为“app mode”,如 Safari。
- <!
- <!
- <link rel="manifest" href="manifest.json">
- <!
- <meta name="mobile-web-app-capable" content="yes">
- <!
- <link rel="icon" sizes="192x192" href="highres-icon.png">
Microsoft Internet Explorer
- <meta http-equiv="x-ua-compatible" content="ie=edge">
- <meta name="skype_toolbar" content="skype_toolbar_parser_compatible">
- <!
- <meta name="msapplication-tap-highlight" content="no">
- <!
- <meta name="application-name" content="Sample Title">
- <meta name="msapplication-tooltip" content="A description of what this site does.">
- <meta name="msapplication-starturl" content="http://example.com/index.html?pinned=true">
- <meta name="msapplication-navbutton-color" content="#FF3300">
- <meta name="msapplication-window" content="width=800;height=600">
- <meta name="msapplication-task" content="name=Task 1;action-uri=http://host/Page1.html;icon-uri=http://host/icon1.ico">
- <meta name="msapplication-task" content="name=Task 2;action-uri=http://microsoft.com/Page2.html;icon-uri=http://host/icon2.ico">
- <meta name="msapplication-badge" value="frequency=NUMBER_IN_MINUTES;polling-uri=http://example.com/path/to/file.xml">
- <meta name="msapplication-TileColor" content="#FF3300">
- <meta name="msapplication-TileImage" content="path/to/tileimage.jpg">
- <meta name="msapplication-config" content="http://example.com/browserconfig.xml">
- <meta name="msapplication-notification" content="frequency=60;polling-uri=http://example.com/livetile;polling-uri2=http://example.com/livetile2">
- <meta name="msapplication-task-separator" content="1">
应用链接
- <!
- <meta property="al:ios:url" content="applinks://docs">
- <meta property="al:ios:app_store_id" content="12345">
- <meta property="al:ios:app_name" content="App Links">
- <!
- <meta property="al:android:url" content="applinks://docs">
- <meta property="al:android:app_name" content="App Links">
- <meta property="al:android:package" content="org.applinks">
- <!
- <meta property="al:web:url" content="http://applinks.org/documentation">
- <!
国内的浏览器
360 浏览器
- <!
- <meta name="renderer" content="webkit|ie-comp|ie-stand">
QQ 移动浏览器
- <!
- <meta name="x5-orientation" content="landscape/portrait">
- <!
- <meta name="x5-fullscreen" content="true">
- <!
- <meta name="x5-page-mode" content="app">
UC 移动浏览器
- <!
- <meta name="screen-orientation" content="landscape/portrait">
- <!
- <meta name="full-screen" content="yes">
- <!
- <meta name="imagemode" content="force">
- <!
- <meta name="browsermode" content="application">
- <!
- <meta name="nightmode" content="disable">
- <!
- <meta name="layoutmode" content="fitscreen">
- <!
- <meta name="wap-font-scale" content="no">
注意
性能
当启用 GZIP 时,移动 href 属性到该元素的开头以提高压缩,因为 href 属性被用于 a、base 和 link 标签。
示例:
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet">
其他资源
相关项目
其他格式
翻译
- 英语/English
- 巴西葡萄牙语/Brazilian Portuguese
- 意大利语/Italian
- 日语/Japanese
- 俄罗斯语/Russian/Русский
- 土耳其语/Turkish/Türkçe
- 韩语/Korean
贡献
开启一个 issue 或一个 pull 请求来提出修改或补充。
指南
HEAD 仓库由两个分支组成:
1、master
对该分支包含的 README.md 文件的修改会自动反映在 <Head> Cheat Sheet 网站上。 所有对照表内容的更改都应该针对此文件。
请按照下列步骤 pull 请求:
- 只修改一个标签,或一次一组相关的标签
- 对属性使用双引号
- 请不要在自我闭合的元素中使用斜线 —— 即便 HTML5 规范中说,他们是可选的
- 考虑在文档中加入链接以支持你所提到的变化
2. gh-pages
该分支负责 <Head> Cheat Sheet 网站。我们使用 Jekyll 通过 GitHub Pages 服务来部署 README.md Markdown 文件。所有网站相关的修改必须集中在这里。
你可能需要通过 Jekyll 文档 来了解 Jekyll 是如何在该分支上工作的。
本文作者:Joshbuchea
来源:51CTO