下述代码适合任意一款模板,因为直接调用的是ZblogPHP1.5自带的标签。

我们常规可见的代码如下:

<title>{$name}-{$title}</title>
<meta name="keywords" content="你的网站关键词" />
<meta name="description" content="你的网站描述" />

替换成下述代码,可实现首页、列表页、文章页、标签页标题显示第几页,实现列表页、文章页、标签页、单页自动设置页面描述,文章页、单页自动设置标签为关键词。

<title>{if $type=="index"}{$name}-{$title}{elseif $type=="category"&&$page=="1"}{$category.Name}_{$name}{elseif $type=="category"&&$page>"1"}{$category.Name}-第{$page}页_{$name}{elseif $type=="tag"&&$page=="1"}{$tag.Name}_{$name}{elseif $type=="tag"&&$page>"1"}{$tag.Name}-第{$page}页_{$name}{elseif $type=="date"&&$page=="1"}{$title}_{$name}{elseif $type=="date"&&$page>"1"}{$title}_{$name}{elseif $type=="article"}{$title}_{$name}{elseif $type=="page"}{$title}_{$name}{else}{$title}-{$name}{/if}</title>
{if $type=='index'}
<meta name="keywords" content="你的网站关键词" /> <meta name="description" content="你的网站描述" /> {elseif $type=='page'}
	<meta name="keywords" content="{$title},{$name}"/>
	{php}$description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');{/php}
	<meta name="description" content="{$title}是{$name}中的一篇文章单页.{$description}"/>
{elseif $type=='article'}
	<meta name="keywords" content="{foreach $article.Tags as $tag}{$tag.Name},{/foreach}" />
	<meta name="description" content="{$article.Title}是{$name}中一篇关于{foreach $article.Tags as $tag}{$tag.Name}{/foreach}的文章,欢迎您阅读和评论,{$name}" />
{elseif $type=='category'}
	<meta name="keywords" content="{$title},{$name}">
	<meta name="description" content="{$title}是{$name}中的分类.{$category.Intro}">
{elseif $type=='tag'}
	<meta name="keywords" content="{$title},{$name}">
	<meta name="description" content="{$title}是{$name}中的标签.{$tag.Intro}">
{else}
	<meta name="Keywords" content="{$title},{$name}" />
	<meta name="description" content="{$title}-{$name}" />