给Movable Type加上Meta Keyword和Description

| No TrackBacks | Previous

  Movable Type默认并没有为单篇文章加入Meta Keyword和Meta Description标签,那么我们可以通过下面的代码,为每一篇文章加入自己的Keyword和Description,这样网站对搜索引擎会更友好。

<meta name="keywords" content="<$mt:EntryKeywords$>" />
<meta name="description" content="<$MTEntryBody words="30"$>" />

  上面两行代码有两种添加方法,一种是直接编辑Entry Template,另一种是编辑HTML Head Module。我先说第一种,编辑Entry Template。

  方法一:登入Movable Type,依次选择Design - Templates,找到Archive Templates中的Entry模板,在模板中<$mt:Include module="HTML Head"$>的后面直接加入上面两行代码,然后重建所有日志。但是使用这种方法添加之后会发现,生成的html代码中的Keyword和Description标签距离其他标签很远,可能不方便后期维护,所以我选择了第二种方法,编辑HTML Head Module。

  方法二:登入Movable Type,依次选择Design - Templates,找到Template Modules中的HTML Head,然后在<link rel="stylesheet" href="<$mt:Link template="styles"$>" type="text/css" />的前面加入下面的代码:

<mt:If name="entry_template">
<meta name="keywords"content="<$mt:EntryKeywords$>" />
<meta name="description" content="<$MTEntryBody words="30"$>" />
</mt:If>

  这样重建所有日志之后,我们在写日志时为每一篇日志设置的keywords也会出现在各自的meta keywords标签中。

  那有朋友又说了,我想让每篇文章添加的Tags也出现在各自的meta keywords中该怎么办呢?

  这个问题也好解决,只要将

<meta name="keywords" content="<$mt:EntryKeywords$>" />
改成
<meta name="keywords" content=" <$mt:EntryKeywords$>,<mt:EntryTags glue=","><$mt:TagName$></mt:EntryTags>" /> 
只是在写日志的时候要注意文章的keywords和tags不要设成一样的就可以了,否则meta keywords会有重复的

 

No TrackBacks

TrackBack URL: http://www.sothink.cn/cgi-bin/mt-tb.fpl/44

About this Entry

This page contains a single entry by SOTHINK published on October 23, 2009 12:38 PM.

fckeditor 使用笔记 - 调用 was the previous entry in this blog.

无法打开hlp文件 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.