(2013-7-28)给blogger博客自定义关键字-Meta Keywords

(2013-7-28)给blogger博客自定义关键字-Meta Keywords

编辑文章

本文HTML永久地址doc

关键字Meta Keywords 的重要性已经不像以前那么重要了,但是设置正确的 Keywords 还是对你的排名有利,本文通过在blogger/Blogspot 添加labels/Tags 作为Meta Keywords,我已经成功在这个博客部署好了,现在访问首页和帖子页面,你都可以看到类似<meta name="keywords" content="" />,下面是详细步骤:

1 添加每篇帖子标签作为帖子页面的关键字

登录博客后台 > 进入html模板 在

<head>

前面增加

<b:if cond='data:blog.pageType == &quot;item&quot;'>
   <b:section id='meta1' showaddelement='no'>
   <b:widget id='Blog2' locked='no' type='Blog'>
   <b:includable id='nextprev'/>
   <b:includable id='backlinks' var='post'/>
   <b:includable id='post' var='post' />
   <b:includable id='status-message'/>
   <b:includable id='comment-form' var='post'/>
   <b:includable id='backlinkDeleteIcon' var='backlink'/>
   <b:includable id='postQuickEdit' var='post'/>
   <b:includable id='commentDeleteIcon' var='comment'/>
   <b:includable id='feedLinks'/>
   <b:includable id='feedLinksBody' var='links'/>
   <b:includable id='comments' var='post'/>
  <b:includable id='main' var='top'><!-- Main Function of Any widget comes with ID 'main' -->
     <!-- Loop Page Posts (only 1 in a post page )-->
     <b:loop values='data:posts' var='post'>
        <b:if cond='data:post.labels'>
           <!-- If the post has labels, make Meta keywords by looping lables -->
           &lt;meta name=&quot;keywords&quot; content=&quot;<b:loop values='data:post.labels' var='label'><data:label.name/><b:if cond='data:label.isLast != &quot;true&quot;'>,</b:if></b:loop>&quot; /&gt;
        </b:if>
     </b:loop>
  </b:includable>
   </b:widget>
   </b:section>
<b:else/>
<div class='section' id='meta1'><div class='widget Blog' id='Blog2'>
<meta name="keywords" content="" />
</div></div>
</b:if>

解释:为什么要在<head>前面添加呢,主要是<head></head>这对标签里面不能增加<b:section,效果是这样就会在每篇帖子(item) <head>前面增加下面类似语句

<div class='section' id='meta1'><div class='widget Blog' id='Blog2'>
<meta name="keywords" content="帖子标签名称" />
</div></div>

非帖子(item)类型的页面<head>前面增加下面

<div class='section' id='meta1'><div class='widget Blog' id='Blog2'>
<meta name="keywords" content="" />
</div></div>

2 给首页增加静态的关键字Meta Keywords

<b:include data='blog' name='all-head-content'/>

后面增加

<b:if cond='data:blog.pageType == &quot;index&quot;'>
  <meta name='keywords' content='google blogger 云平台 nginx seo' />
<b:else/>
</b:if>

页面类型为index包含为homepage, labels page and yearly archive page,就是首页,标签页,年份归档页,我这里是写目前我博客的关键字,你需要替换成你自己的。

3 调整第一步生成的关键字代码调整到head后面

我使用nginx 作为反向代理blogger,详细请访问使用nginx反向代理blogger博客配置

配置nginx反向代理使用substitutions4nginx模块正则表达式替换相应的语句

subs_filter "<div class='section' id='meta1'><div class='widget Blog' id='Blog2'>" '' or;
        subs_filter '</div></div>' '' or;
        subs_filter '^<head>' '' or;
        subs_filter '<meta name=\"keywords\" content=\"(.*)\" />' '<head>\n<meta name=\"keywords\" content=\"$1\" />' or;
        subs_filter '<meta content=\'(.*)\' name=\'keywords\'/>' '<head>' or;

4 参考资料

www.moretechtips.net/2009/03/blogger-seo-tip-use-post-labels-as-meta.html

没有评论 :

发表评论