解决蜘蛛索引时,存在“该页面上存在多个 h1 标记” 问题
修改位置:/handsome/libs/Content.php
V9.2.1版本大概位于471行

原因:因为文章页面存在阅读模式,所以会存在两个h1,将h1修改为h2即可。
文章中的外链未做优化处理造成权重流失,需要添加 rel=”nofollow” 属性
Handsome 主题外链处理分为以下三种:
- 文章外链
- 全站友情链接
内页友情链接
文章外链
修改位置:
/handsome/libs/content/ScodeContent.php
V9.2.1版本大概位于304行。

内页友情链接
修改位置:/handsome/libs/Content.php
V9.2.1版本大概位于948行。

站友情链接
修改位置:/handsome/component/aside.php
V9.2.1版本大概位于215行。

在 rel='noopener添加 nofollow 即可。
文章末尾添加以 tag 为推荐条件的相关文章推荐
修改位置:/handsome/post.php
V9.2.1版本在100行代码结束后,开始之前添加如下代码

<!--相关推荐-->
<div class="tab-content clear">
<h3 class="widget-title m-t-none text-md"><?php _me("相关文章") ?>
<small><i class="fontello-bell" data-toggle="tooltip" title="我们将根据本文的tag进行相关文章的推荐"></i>
</small>
</h3>
<div id="relatedPosts" >
<ul class="list-group-item nav nav-list">
<?php $this->related(5)->to($relatedPosts); ?>
<?php if ($relatedPosts->have()): ?>
<?php while ($relatedPosts->next()): ?>
<li class="tocify-item text-second">
<a href="<?php $relatedPosts->permalink(); ?>" title="<?php $relatedPosts->title(); ?>"><?php $relatedPosts->title(); ?></a>
</li>
<?php endwhile; ?>
<?php else : ?>
<li>暂无相关推荐</li>
<?php endif; ?>
</ul>
</div>
</div> 仅仅是希望在文章页中进行相关文章的展示,个人博客单页面承载的链接不建议过多。上面写的是最多5个。
可以根据想要显示的位置自行调整代码位置。
删除网站标题连接符两边的空格,增加网页标题有效信息内容
将空格-空格换成-,如果标题字数多的博客可以将其两边的空格去掉获得 1-2 字的展现。
修改位置:/handsome/libs/Content.php
V9.2.1版本大概位于877、882行。

删除-左右的空格即可。
修复首页description和keywords显示BUG
描述添加到页面源代码的 部分中: <meta name='description' content='在此处输入有关页面内容的描述性、富含关键字的文本。'>。
搜索引擎可能会使用搜索引擎结果页面(SERP)中的 标记中所提供的描述。编写良好的描述将与页面的内容相契合,并且与搜索者的意图相关,从而帮助你提高网站流量,因为在进行搜索时,这种描述有助于提高页面的点击率。
修改位置:/handsome/component/header.php
V9.2.1版本位于54行。

找到第54行,也就是<?php $this->header(Content::exportGeneratorRules($this)); ?>这一行,将这一行替换成如下内容。
<?php
if($this->is('index')){
$this->header(Content::exportGeneratorRules($this));
}else{
$custom_headerb = '';
if(!is_null($this->fields->description)){
$custom_headerb .= 'description=';
$custom_headerb .= $this->fields->description;
}
if(!is_null($this->fields->keywords)){
if(strcmp($custom_headerb,'') == 0){
$custom_headerb .= 'keywords=';
$custom_headerb .= $this->fields->keywords;
}else{
$custom_headerb .= '&keywords=';
$custom_headerb .= $this->fields->keywords;
}
}
if(strcmp($custom_headerb,'') == 0){
$this->header(Content::exportGeneratorRules($this));
}else{
$this->header($custom_headerb);
}
}
?>在文章编辑器中,增加description、keywords字段。

控制台可以看到已经添加成功。

每次在文章编辑页面添加字段十分麻烦,修改代码添加自定义文章编辑页面。
找到/handsome/functions_mine.php中的 function themeFields(Typecho_Widget_Helper_Layout $layout) 函数。
在函数最后增加如下代码:
$description = new Typecho_Widget_Helper_Form_Element_Text('description', NULL, NULL, _t('描述'), _t('简单一句话描述'));$description->input->setAttribute('class', 'text w-100');
$layout->addItem($description);
$keywords = new Typecho_Widget_Helper_Form_Element_Text('keywords', NULL, NULL, _t('关键词'), _t('多个关键词用英文下逗号隔开'));$keywords->input->setAttribute('class', 'text w-100');
$layout->addItem($keywords);
查看编辑器,修改成功。

降低分页、标签页对于首页、文章页的权重分散
经过一段时间的使用,发现搜索引擎并不收录文章页面,而经常性收录以下页面:
- 各种文章标签的页面
- 各种关键词搜索页面
- 各种文章分类的页面
为了让搜索引擎更多的收录文章,而不是其他页面,故在蜘蛛屏蔽文件 robots.txt 中增加以下信息:
Disallow: /category
Disallow: /tag
Disallow: /search用于告诉蜘蛛屏蔽上述界面,不进行爬虫。
robots.txt 文件放在网站根目录。