首页 » 网站优化 » 正文

zblog SEO title页面标题优化代码

2018年06月29日 14:48:50

首先这个SEO代码是拷贝懿古今的SEO文件,觉得很好久拿来用了,非常感谢!由于不会调用后台主题设置,所以直接代码改主题文件得了。在主题文件目录中新建SEO.PHP文件与header同一目录,然后在主题头文件header.php中的<head>部分加入

zblog SEO title页面标题优化代码 网站优化

	<!--TDK-->
	{template:seo}
    <!--TDK end-->

seo.php文件内容如下

{if $type=='index'}
<title>{$name}{if $page>'1'}-第{$pagebar.PageNow}页{/if}--{$subname}</title>
<meta name="Keywords" content="虎子博客">
<meta name="description" content="虎子博客是一个专注于研究百度谷歌搜索引擎(SEO)优化、电商运营的个人自媒体博客,博客用于记录网站博客SEO优化过程,分享运营经验与心得。">
{elseif $type=='category'} 
<title>{if $category.Metas.Blogs_fltitle}{$category.Metas.Blogs_fltitle}{else}{$category.Name}{/if}{if $page>'1'}-第{$pagebar.PageNow}页{/if}-{$name}</title>
<meta name="Keywords" content="{if $category.Metas.Blogs_flgjc}{$category.Metas.Blogs_flgjc}{else}{$category.Name}{/if},{$name}">
<meta name="description" content="{$category.Intro}">
{elseif $type=='article'}
<title>{$title}-{$name}</title>
{php}
    $aryTags = array();
    foreach($article->Tags as $key){
      $aryTags[] = $key->Name;
    }
    if(count($aryTags)>0){
        $keywords = implode(',',$aryTags);
    } else {
        $keywords = $zbp->name;
    }
	if (strlen($article->Intro)>0){
	$description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Intro,'[nohtml]'),135)).'...');
	}else{
    $description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');
	}
{/php}
<meta name="keywords" content="{$keywords}"/>
<meta name="description" content="{$description}"/>
<meta name="author" content="{$article.Author.StaticName}">
{elseif $type=='page'}
<title>{if $article.Metas.Blogs_pstitle}{$article.Metas.Blogs_pstitle}{else}{$title}{/if}-{$name}</title>
<meta name="keywords" content="{if $article.Metas.Blogs_psguanjianci}{$article.Metas.Blogs_psguanjianci}{else}{$title},{$name}{/if}"/>
{php}
	if (strlen($article->Metas->Blogs_psmiaoshu)>0){
	$description = $article->Metas->Blogs_psmiaoshu;
	}else{
    $description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');
	}
{/php}
<meta name="description" content="{$description}"/>
<meta name="author" content="{$article.Author.StaticName}">  
{elseif $type=='tag'}  
<title>{if $tag->Metas->Blogs_bqtitle}{$tag.Metas.Blogs_bqtitle}{else}{$tag.Name}{/if}{if $page>'1'}-第{$pagebar.PageNow}页{/if}-{$name}</title>
<meta name="Keywords" content="{if $tag->Metas->Blogs_bqgjc}{$tag.Metas.Blogs_bqgjc}{else}{$tag.Name}{/if},{$name}">
<meta name="description" content="{$tag.Intro}">
{else}
<title>{$title}-{$name}{if $page>'1'}-第{$pagebar.PageNow}页{/if}</title>
<meta name="Keywords" content="{$title},{$name}">
<meta name="description" content="{$title}-{$name}{if $page>'1'}-第{$pagebar.PageNow}页{/if}"> 
{/if}


  • 评论(0)

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。