第一部分:模板修改
	1、js部分:刪除或使用現(xiàn)有組件替換
	2、調(diào)用百度mip文件:
	head里加<link rel="stylesheet" type="text/css"href="https://mipcache.bdstatic.com/static/mipmain-v1.1.1.css">
	body里加<script src="https://mipcache.bdstatic.com/static/mipmain-v1.1.2.js"></script>
	3、head里加<link rel="canonical"href="{dede:global.cfg_basehost/}{dede:field name='arcurl'/}" >,通過dedecms標(biāo)簽直接調(diào)用當(dāng)前頁url。
	4、外部通用css文件:建議將css文件中的樣式代碼嵌入<style mip-custom>…</style>中,另存為模板文件(如css.htm),用{dede:includefilename="css.htm"/}替換相關(guān)模板中的<link rel="stylesheet" type="text/css"href="…" />。
	模板中的內(nèi)聯(lián)css可人工進(jìn)行查找替換,合并至<stylemip-custom>中。(雖在下面代碼中可以自動(dòng)進(jìn)行處理,但從靜態(tài)文件生成性能角度考慮,還是建議人工先將模板中的內(nèi)聯(lián)樣式一次性整改好。)
	注:以上操作大多可通過批量查找替換來完成,看似需要修改很多,但實(shí)際工作量并不大。
	第二部分:程序文件修改
	 
	· 靜態(tài)生成移動(dòng)站:
	找到 /include/dedetag.class.php文件中解析模板輸出為文件的函數(shù):
	    function SaveTo($filename)
	    {
	        $fp = @fopen($filename,"w")or die("DedeTag Engine Create File False");
	        fwrite($fp,$this->GetResult());
	        fclose($fp);
	}
	替換為(部分代碼可根據(jù)實(shí)際情況進(jìn)行改動(dòng)):
	     //路徑轉(zhuǎn)換函數(shù)文件。$content:代碼源,$feed_url:首頁,$f_url:相對(duì)路徑的目錄部分
	     function relative_to_absolute($content,$protocol, $domain, $f_url) {  
	                   //根目錄相對(duì)路徑(如href="/a/b.html")轉(zhuǎn)換
	                   $new_content =preg_replace('/href/s*/=/s*([/'"])/s*///','href=//1'.$protocol.$domain.'/', $content);
	                   $new_content =preg_replace('/src/s*/=/s*([/'"])/s*///', 'src=//1'.$protocol.$domain.'/',$new_content);
	                   //當(dāng)前頁相對(duì)路徑(如href="a/b.html")轉(zhuǎn)換
	                   $new_content =preg_replace('/href/s*/=/s*([/'"])(?!(http|https):////)/','href=//1'.$protocol.$domain.$f_url,$new_content);
	                   $new_content =preg_replace('/src/s*/=/s*([/'"])(?!(http|https):////)/','src=//1'.$protocol.$domain.$f_url, $new_content);
	                   return $new_content;
	     }
	    function SaveTo($filename)
	    {                 
	        $fp=@fopen($filename,"w") ordie("DedeTag Engine Create File False");
	                   if(substr($_SERVER['PHP_SELF'],-6)=='_m.php'||substr($filename,-13)=='/m/index.html'){ //跳轉(zhuǎn)適配站識(shí)別是否為移動(dòng)端生成,不影響pc端的gbk編碼。移動(dòng)端為獨(dú)立站點(diǎn)需去掉此判斷條件。
	                            $f_url=explode('www.域名.com/m',dirname($filename));//分割路徑,獲取當(dāng)前頁相對(duì)路徑的目錄部分
	                            //如dirname($filename)得到的本地絕對(duì)路徑為D:/wwwroot/www.域名.com/m/yygk/xwzx,用網(wǎng)站目錄“www.域名.com/m”作為標(biāo)識(shí)分割路徑,得到目錄部分“/yygk/xwzx”。
	                            $html=$this->GetResult();
	                            $html=$this->relative_to_absolute($html,'http://','m.域名.com',$f_url[1].'/');//相對(duì)路徑轉(zhuǎn)換絕對(duì)路徑
	                            $html=str_replace('<metacharset="gb2312">','<metacharset="utf-8">',iconv('gbk','utf-8//ignore',$html)); //轉(zhuǎn)換為utf-8編碼聲明,fwrite會(huì)以此生成對(duì)應(yīng)編碼的靜態(tài)頁面
	                            $html=str_replace('<a','<a target="_blank" ',$html); //<a>標(biāo)簽加target
	                            $html=str_replace('<img','<mip-img ',$html);  //替換<img>標(biāo)簽
	                            /* 主要針對(duì)編輯器生成的內(nèi)聯(lián)樣式,將內(nèi)聯(lián)樣式轉(zhuǎn)換到head的style標(biāo)簽中 */
	                            if(preg_match_all('//sstyle/s*/=/s*[/'"](.*?)[/'"]/',$html,$css)){
	                                     $css0=array_unique($css[0]);//過濾重復(fù)style                                 
	                                     foreach($css0as $k => $v){
	                                               $html=str_replace($v,'class="mip_add_css_'.$k.'"',$html); //mip_add_css_為自定義樣式名前綴,可自行修改,但需避免與原有樣式名重復(fù)
	                                               $temp_name='mip_add_css_'.$k;
	                                               $$temp_name=$css[1][$k];
	                                               $add_css.='.'.$temp_name.'{'.$css[1][$k]."}/n";
	                                     }
	                                     $html=str_replace('<stylemip-custom>',"<style mip-custom>/n".$add_css,$html);
	                            }
	                            fwrite($fp, $html);
	                   }else{ //pc端執(zhí)行
	                            fwrite($fp,$this->GetResult());
	                   }
	        fclose($fp);
	    }
	注:該方案初步測試成功,因生成靜態(tài)文件時(shí)處理程序增加,理論上來說會(huì)對(duì)生成效率有所影響。另外,不排除存在問題的可能性,如有問題或其他想法可回帖共同研究探討。
	 
	· 默認(rèn)動(dòng)態(tài)移動(dòng)站:
	1、修改/m目錄下index.php、list.php、view.php三個(gè)php文件的編碼,改為utf-8。
	 
	2、找到 /include/dedetag.class.php文件中解析模板直接輸出的函數(shù):
	    function Display()
	    {
	        echo $this->GetResult();
	    }
	替換為:
	    function Display()
	    {
	        $html=str_replace('<meta charset="gb2312">','<meta charset="utf-8">',$this->GetResult()); //轉(zhuǎn)換為utf-8編碼聲明,此處源內(nèi)容$this->GetResult()不需要轉(zhuǎn)編碼
	        echo $html;
	    }
	 
	如此即可以u(píng)tf-8編碼輸出動(dòng)態(tài)頁面,其他處理可參照上面靜態(tài)生成站點(diǎn)方案中的代碼。