PC端head代码标准
约 864 字大约 3 分钟
2025-07-31
一、首页head代码规范:
\<head>
\<meta charset="UTF-8"> \<!--页面编码声明-->
\<title>{dede:global.cfg_webname/}\</title>
\<meta name="description" content="{dede:global.cfg_description/}" />
\<meta name="keywords" content="{dede:global.cfg_keywords/}" />
{dede:include filename='meta.htm'/}
\<link rel="alternate" media="only screen and(max-width: 640px)" href="{dede:global.cfg_basehost function='replacewww(@me)'/}" > \<!--对应移动-->
\<meta name="mobile-agent" content="format=html5;url={dede:global.cfg_basehost function='replacewww(@me)'/}/"> \<!--对应移动-->
\<meta name="mobile-agent" content="format=xhtml;url={dede:global.cfg_basehost function='replacewww(@me)'/}/"> \<!--对应移动-->
\<meta name="mobile-agent" content="format=wml;url={dede:global.cfg_basehost function='replacewww(@me)'/}/"> \<!--对应移动-->
\<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "{dede:global.cfg_basehost/}",
"appid": "写自己的",
"title": "{dede:global.cfg_webname/}",
"description": "{dede:global.cfg_description/}",
"upDate": "{dede:php runphp='yes'}$ntime = time();@me=strftime('%Y-%m-%d',$ntime)."T".@me=strftime('%H:%M:%S',$ntime);{/dede:php}"
}
\</script>\<!--熊掌号-->
\</head>
二、栏目页head代码规范:
\<head>
\<meta charset="UTF-8">
\<title>{dede:field.seotitle/}-{dede:global.cfg_indexname/}\</title>
\<meta name="description" content="{dede:field.description function='html2text(@me)'/}">
\<meta name="keywords" content="{dede:global.cfg_keywords/}">
{dede:include filename='meta.htm' /}
\<meta name="mobile-agent" content="format=html5;url={dede:global.cfg_basehost function=" replacewww(@me)"/}{dede:field name='typedir'/}/"> \<!--对应移动-->
\<meta name="mobile-agent" content="format=xhtml;url={dede:global.cfg_basehost function=" replacewww(@me)"/}{dede:field name='typedir'/}/"> \<!--对应移动-->
\<meta name="mobile-agent" content="format=wml;url={dede:global.cfg_basehost function=" replacewww(@me)"/}{dede:field name='typedir'/}/"> \<!--对应移动-->
\<link rel="alternate" media="only screen and(max-width: 640px)" href="{dede:global.cfg_basehost function=" replacewww(@me)"/}{dede:field name='typedir'/}/"> \<!--对应移动-->
\<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "{dede:global.cfg_basehost/}{dede:field name='typedir'/}/",
"appid": "自己的",
"title": "{dede:field.seotitle/}-{dede:global.cfg_indexname/}",
"description": "{dede:field name='description' function='html2text(@me)'/}",
"upDate": "{dede:php runphp='yes'}$ntime = time();@me=strftime('%Y-%m-%d',$ntime)."T".@me=strftime('%H:%M:%S',$ntime);{/dede:php}"
}
\</script>
\</head>
三、文章页head代码规范:
\<head>
\<meta charset="UTF-8">
\<title>{dede:field.title/}_{dede:global.cfg_indexname/}\</title>
\<meta name="description" content="{dede:field.description function='html2text(@me)'/}">
\<meta name="keywords" content="{dede:field.keywords/}">
{dede:include filename='meta.htm' /}
\<meta name="mobile-agent" content="format=html5;url={dede:field name='arcurl' function=" replacewww(@me) "/}"> \<!--对应移动-->
\<meta name="mobile-agent" content="format=xhtml;url={dede:field name='arcurl' function=" replacewww(@me) "/}"> \<!--对应移动-->
\<meta name="mobile-agent" content="format=wml;url={dede:field name='arcurl' function=" replacewww(@me) "/}"> \<!--对应移动-->
\<link rel="alternate" media="only screen and(max-width: 640px)" href="{dede:field name='arcurl' function=" replacewww(@me) "/}"> \<!--对应移动-->
\<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "{dede:field name='arcurl'/}",
"appid": "写自己的",
"title": "{dede:field.title/}-{dede:global.cfg_indexname/}",
"description": "{dede:field name='description' function='html2text(@me)'/}",
"pubDate": "{dede:field.senddate function="MyDate('Y-m-d',@me)"/}T{dede:field.senddate function="MyDate('H:i:s',@me)"/}",
"upDate": "{dede:php runphp='yes'}$ntime = time();@me=strftime('%Y-%m-%d',$ntime)."T".@me=strftime('%H:%M:%S',$ntime);{/dede:php}"
}
\</script>
\</head>
四、PC端通用meta代码:
\<!--meta开始-->
\<meta name="robots" content="all"> \<!--可以抓取本页,而且可以顺着本页继续索引别的链接-->
\<meta name="applicable-device" content="pc"> \<!--页面端口声明-->
\<meta name="renderer" content="webkit|ie-stand"> \<!--优先极速、标准内核渲染,-->
\<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> \<!--浏览器兼容-->
\<meta http-equiv="Cache-Control" content="no-transform"> \<!--禁止转码-->
\<meta http-equiv="Cache-Control" content="no-siteapp"> \<!--禁止转码-->
\<meta name="author" content="{dede:global.cfg_indexname/}">
\<meta name="copyright" content="本网站版权归{dede:global.cfg_indexname/}所有">
\<meta name="format-detection" content="telephone=no"> \<!--禁止当前页面电话号码显示为超链接-->
\<meta name="format-detection" content="email=no"> \<!--禁止当前页面电话号码显示为超链接-->
\<meta name="format-detection" content="adress=no"> \<!--禁止当前页面地址显示为超链接-->
\<link rel="shortcut" icon="icon" type="image/ico" href="/favicon.ico">
\<link rel="icon" href="/favicon.ico" type="image/x-icon">
\<script type="text/javascript">
var str=window.top.location.search;
var gourl=window.location.pathname;
host = window.location.host;
murl=host.replace(/www/,'m')
if (str.indexOf('?pc')==-1){
var $nav = navigator.userAgent;
if($nav.match(/(iPhone|iPod|Android|ios|iPad|Linux;)/i)){
if(window.location.host == host){
location.href = 'http://'+murl+gourl+str;
}
}
}
\</script>
\<!--meta结束-->
更新: 2019-12-20 16:16:45
原文: <https://www.yuque.com/seoers/uyyd4f/ydou1g>