1. 程式人生 > >網站內頁移動適配Meta標註宣告 (DEDE 版)

網站內頁移動適配Meta標註宣告 (DEDE 版)

index 頁面

<meta name="mobile-agent" content="format=html5;url=https://m.mornread.com">
<meta name="mobile-agent" content="format=xhtml;url=https://m.mornread.com">
<link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.mornread.com" />
<meta http-equiv="mobile-agent" content="format=wml; url=https://m.mornread.com">

分類頁面:

<meta name="mobile-agent" content="format=html5;url=https://m.mornread.com{dede:type typeid='0' row=1}[field:typelink/]{/dede:type}">
<meta name="mobile-agent" content="format=xhtml;url=https://m.mornread.com{dede:type typeid='0' row=1}[field:typelink/]{/dede:type}">
<link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.mornread.com{dede:type typeid='0' row=1}[field:typelink/]{/dede:type}" />
<meta http-equiv="mobile-agent" content="format=wml; url=https://m.mornread.com{dede:type typeid='0' row=1}[field:typelink/]{/dede:type}">

這裡的typeid='0′row=1 即表示獲取當前欄目頁的地址,這個方法通用語頂級欄目頁和次級欄目頁。

內容頁面:

   <meta name="mobile-agent" content="format=html5;url=https://m.mornread.com{dede:field name='arcurl'/}">
   <meta name="mobile-agent" content="format=xhtml;url=https://m.mornread.com{dede:field name='arcurl'/}">
   <link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.mornread.com{dede:field name='arcurl'/}" />
   <meta http-equiv="mobile-agent" content="format=wml; url=https://m.mornread.com{dede:field name='arcurl'/}">

針對不同的移動端網站,我們還需要做下applicable-device標註宣告,主要根據自己網站的情況分以下幾種,請結合自己的網站情況使用:

僅PC協議(新增在獨立pc頁面頭部) <meta name="applicable-device" content="pc">
僅PH協議 (新增在移動端網站頁面頭部) <meta name="applicable-device"content="mobile">
自適應協議 (新增在獨立pc頁面頭部) <meta name="applicable-device"content="pc,mobile">