「翻译」一份可以放在web文档head标签中的内容清单

2018-11-08  本文已影响14人  阿爽Alisa

HEAD

一份可以放在web文档head标签中的内容清单
原文链接:https://gethead.info
github地址:github

内容列表

必要信息

以下是所有web文档的必要元素

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!--
为了确保文档的正确渲染,以上两个meta标记必须首先出现在<head>标签中,
其他的head元素应该在这两个标记之后出现。                
-->
<title>Page Title</title>

⬆ 返回顶部

网页元素

<head>标签中,可以包含的有效的元素有:meta,link, title, style, script, noscriptbase.
这些元素为文档应该如何被web技术(如:浏览器、搜索引擎、机器人等)识别、渲染提供了信息,

<!--
为web文档设置字符编码方式,以便所有以utf-8编码的字符(比如emoji表情符号)都能正确地呈现出来。
-->
<meta charset="utf-8">

<!-- 设置文档的标题 -->
<title>Page Title</title>

<!-- 为所有的通过相对路径引用的资源设置默认的地址或目标设置 -->
<base href="https://example.com/page.html">
<base target="_blank">

<!-- 链接外部CSS文件 -->
<link rel="stylesheet" href="styles.css">

<!-- 用于在此标签内添加文档内嵌样式 -->
<style>
/* ... */
</style>

<!-- JavaScript标签和 noscript标签 -->
<script src="script.js"></script>
<script>
// javascript 语句在此标签内执行
</script>
<noscript>
<!-- 在这里添加不支持JS时的替代内容 -->
</noscript>

⬆ back to top

Meta元信息

<!--
  为了确保文档的正确渲染,以上两个meta标记必须首先出现在<head>标签中,
  其他的head元素应该在这两个标记之后出现。

  译者注:
  viewport: 它提供有关视口初始大小的提示,仅供移动设备使用
  width=device-width:表示文档宽度是设备屏幕的宽度
  initial-scale=1.0:一个0.0 到10.0之间的正数,表示文档初始的缩放比例
  shrink-to-fit: 阻止缩放的ios写法
  
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!--
  定义控制资源加载的位置
  应尽早在<head>标签中使用,因为这个标签仅作用于在它之后声明的资源。

  译者注:http-equiv这个枚举属性定义了能改变服务器和用户引擎行为的编译.
  content-security-policy:内容安全策略,它允许页面作者定义当前页的内容策略。内容策略主要指定允许的服务器源和脚本端点,这有助于防止跨站点脚本攻击。
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">

<!-- 定义web应用的名称 (仅在网站被用作应用程序时使用) -->
<meta name="application-name" content="Application Name">

<!-- 为Chrome,Firefox OS 和 Opera 设置主题颜色 -->
<meta name="theme-color" content="#4285f4">

<!-- 文档的简短描述 (限制在150字符以内) -->
<!-- 这有可能被用作搜索引擎搜索结果的一部分 -->
<meta name="description" content="A description of the page">

<!-- 控制搜索引擎抓取和索引的行为 -->
<meta name="robots" content="index,follow"><!-- 所有搜索引擎 -->
<meta name="googlebot" content="index,follow"><!-- Google写法 -->

<!-- 告诉Google不要显示附加链接搜索框 -->
<meta name="google" content="nositelinkssearchbox">

<!-- 告诉谷歌不要为此文档提供翻译 -->
<meta name="google" content="notranslate">

<!--验证网站所有权 -->
<meta name="google-site-verification" content="verification_token"><!-- Google Search Console(谷歌站长工具) -->
<meta name="yandex-verification" content="verification_token"><!-- Yandex Webmasters(俄罗斯搜索引擎Yandex网站站长中心) -->
<meta name="msvalidate.01" content="verification_token"><!-- Bing Webmaster Center 微软必应网站站长中心 -->
<meta name="alexaVerifyID" content="verification_token"><!-- Alexa Console 亚马逊Alexa站长统计-->
<meta name="p:domain_verify" content="code_from_pinterest"><!-- Pinterest Console-->
<meta name="norton-safeweb-site-verification" content="norton_code"><!-- Norton Safe Web 诺顿安全网 -->

<!-- 识别构建文档的软件(如: WordPress, Dreamweaver) -->
<meta name="generator" content="program">

<!-- 文档主题的简短描述 -->
<meta name="subject" content="your document's subject">

<!-- Gives a general age rating based on the document's content -->
<meta name="rating" content="General">

<!-- 允许控制引用信息如何传输 -->
<meta name="referrer" content="no-referrer">

<!-- 禁止自动检测和格式化可能出现的电话号码 -->
<meta name="format-detection" content="telephone=no">

<!-- 通过设置值为“off”完全退出DNS的预获取 -->
<meta http-equiv="x-dns-prefetch-control" content="off">

<!-- 在客户端web浏览器存储cookie以便进行标识 -->
<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]"><!-- 国家代码 (ISO 3166-1): 强制性的, 州代码 (ISO 3166-2): 可选的; 例如: content="US" / content="US-NY" -->
<meta name="geo.placename" content="city/town"><!-- 例如: content="New York City" -->

⬆ 返回顶部

链接

<!-- 指向外联样式表 -->
<link rel="stylesheet" href="https://example.com/styles.css">

<!-- 有助于防止出现重复内容的问题 -->
<link rel="canonical" href="https://example.com/article/?page=2">

<!-- 将当前文档链接到AMP HTML版本 -->
<link rel="amphtml" href="https://example.com/path/to/amp-version.html">

<!-- 链接到一个为web应用指定了安装凭证的JSON文件 -->
<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/article/">

<!-- 提供一个对自身对引用 - 当文档可能包含多种引用时非常有用 -->
<link rel="self" type="application/atom+xml" href="https://example.com/atom.xml">

<!-- 在一个系列的文档中,分别指向第一个、最后一个、上一个、和下一个文档 -->
<link rel="first" href="https://example.com/article/">
<link rel="last" href="https://example.com/article/?page=42">
<link rel="prev" href="https://example.com/article/?page=1">
<link rel="next" href="https://example.com/article/?page=3">

<!-- 在通过第三方服务维护博客时使用 -->
<link rel="EditURI" href="https://example.com/xmlrpc.php?rsd" type="application/rsd+xml" title="RSD">

<!-- 当另一个WordPress博客链接到你的WordPress博客或帖子时,形成自动评论 -->
<link rel="pingback" href="https://example.com/xmlrpc.php">

<!-- 当你在页面上链接到一个 url 时通知它 -->
<link rel="webmention" href="https://example.com/webmention">

<!-- 允许使用Micropub客户端发布到你自己到域名 -->
<link rel="micropub" href="https://example.com/micropub">

<!-- 开启搜索 -->
<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">

<!-- 欲huoqu、欲jiazai、欲浏览 -->
<!-- 更多信息: https://css-tricks.com/prefetching-preloading-prebrowsing/ -->
<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">

⬆ 返回顶部

图标

<!-- 针对IE 10 及以下版本 -->
<!-- Place favicon.ico in the root directory - no tag necessary -->

<!-- 我们需要的最高分辨率的图标 -->
<link rel="icon" sizes="192x192" href="/path/to/icon.png">

<!-- Apple Touch图标 (同样是192x192px的png图标 icon.png) -->
<link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png">

<!-- Safari固定选项卡图标 -->
<link rel="mask-icon" href="/path/to/icon.svg" color="blue">

⬆ 返回顶部

社交

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="">

Twitter Card

<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 Privacy

如果您在网站中嵌入推文,Twitter可以使用您网站上的信息来定制Twitter用户的内容和建议。
More about Twitter privacy options.

<!-- 禁止Twitter将您的网站信息用于个性化目的 -->
<meta name="twitter:dnt" content="on">

Google+ / Schema.org

<html lang="" itemscope itemtype="https://schema.org/Article">
    <head>
      <link rel="author" href="">
      <link rel="publisher" href="">
      <meta itemprop="name" content="Content Title">
      <meta itemprop="description" content="Content description less than 200 characters">
      <meta itemprop="image" content="https://example.com/image.jpg">

注意: 这些标签需要将itemscopeitemtype属性添加到<html>标签中。

Pinterest

根据Pinterest的帮助中心, Pinterest 能让你禁止他人从你的网站保存内容,description是可选的.

<meta name="pinterest" content="nopin" description="Sorry, you can't save from my website!">

Facebook Instant Articles

<meta charset="utf-8">
<meta property="op:markup_version" content="v1.0">

<!-- 你的文章的Web版本的URL -->
<link rel="canonical" href="https://example.com/article.html">

<!-- 用于该文章的样式 -->
<meta property="fb:article_style" content="myarticlestyle">

OEmbed

<link rel="alternate" type="application/json+oembed"
  href="https://example.com/services/oembed?url=http%3A%2F%2Fexample.com%2Ffoo%2F&amp;format=json"
  title="oEmbed Profile: JSON">
<link rel="alternate" type="text/xml+oembed"
  href="https://example.com/services/oembed?url=http%3A%2F%2Fexample.com%2Ffoo%2F&amp;format=xml"
  title="oEmbed Profile: XML">

⬆ 返回顶部

浏览器 / 平台

Apple iOS

<!-- 智能应用Banner -->
<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">

<!-- 启动图标 (180x180px或更大) -->
<link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png">

<!-- 启动屏幕图标 -->
<link rel="apple-touch-startup-image" href="/path/to/launch.png">

<!-- 启动图标标题 -->
<meta name="apple-mobile-web-app-title" content="App Title">

<!-- 启用独立(全屏)模式 -->
<meta name="apple-mobile-web-app-capable" content="yes">

<!-- 状态栏外观(除非启用独立模式否则无效) -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<!-- iOS应用深层链接 -->
<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">

Google Android

<meta name="theme-color" content="#E64545">

<!-- 添加到主屏幕 -->
<meta name="mobile-web-app-capable" content="yes">
<!-- More info: https://developer.chrome.com/multidevice/android/installtohomescreen -->

<!-- 安卓应用深层链接 -->
<meta name="google-play-app" content="app-id=package-name">
<link rel="alternate" href="android-app://package-name/http/url-sample.com">

Google Chrome

<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/APP_ID">

<!-- 禁用翻译提示 -->
<meta name="google" content="notranslate">

Microsoft Internet Explorer

<!-- 强制 IE 8/9/10 使用他们最新的渲染引擎 -->
<meta http-equiv="x-ua-compatible" content="ie=edge">

<!-- 通过Skype Toolbar brwoser扩展 禁用自动检测和格式化可能的电话号码 -->
<meta name="skype_toolbar" content="skype_toolbar_parser_compatible">

<!-- Windows 标题 -->
<meta name="msapplication-config" content="/browserconfig.xml">

browserconfig.xml所需的最小xml标记;

<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
   <msapplication>
     <tile>
        <square70x70logo src="small.png"/>
        <square150x150logo src="medium.png"/>
        <wide310x150logo src="wide.png"/>
        <square310x310logo src="large.png"/>
     </tile>
   </msapplication>
</browserconfig>

⬆ 返回顶部

中国的浏览器

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">

<!-- UC浏览器即使在"文本模式"也将显示图片-->
<meta name="imagemode" content="force">

<!-- 页面将以“应用程序”模式显示(全屏,禁止手势等) -->
<meta name="browsermode" content="application">

<!-- 在此页面中禁用UC浏览器的夜间模式 -->
<meta name="nightmode" content="disable">

<!-- 简化页面以减少数据传输 -->
<meta name="layoutmode" content="fitscreen">

<!-- 当页面文字过多时,禁用UC浏览器的缩放字体功能" -->
<meta name="wap-font-scale" content="no">

⬆ 返回顶部

应用列表

<!-- iOS -->
<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">

<!-- Android -->
<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="https://applinks.org/documentation">

⬆ 返回顶部

其他资源

⬆ 返回顶部

相关项目

⬆ 返回顶部

其他格式

翻译

⬆ 返回顶部

贡献

新建一个issue或发起一个pull request 来提出修改意见或补充

指南

HEAD仓库包含两个分支;

1. master

此分支包含的README.md文件会自动更新反映在gethead.info网站。所有对列表的内容更改都应该针对此文件。

根据以下步骤发起pull请求:

2. gh-pages

该分支负责gethead.info网站。我们使用Jekyll通过GitHub Pages部署README.md Markdown文件。 所有与网站相关的修改必须控制在此处。

在此分支上工作之前,您可能想要浏览Jekyll Docs并了解Jekyll的工作原理。

贡献者

查看所有的超级棒的贡献者们.

作者

Josh Buchea

翻译

Alisa

许可

CC0

⬆ 返回顶部

上一篇 下一篇

猜你喜欢

热点阅读