教程
Typecho关于seo的一些优化
1416

关于typecho的收录优化,一个是文章seo和搜索优化,另一个就与博客加载速度相关了,至于之后还不收录,那就是百度太高冷了,我这小站不配了。

文章自定义字段功能设置描述与关键词

在主题functions.php文件中的function themeFields ($layout) {}添加下列代码:

    $keywords = new Typecho_Widget_Helper_Form_Element_Text('keywords', NULL, NULL, _t('文章keywords关键词'), _t('SEO设置'));
    $description = new Typecho_Widget_Helper_Form_Element_Text('description', NULL, NULL, _t('文章description描述'), _t('SEO设置'));
    $layout->addItem($keywords);
    $layout->addItem($description);

然后发表文章就可以在文章下面的自定义字段中多填一些文章的keywords和description设置
061201
这些都可以在文章内的head里显示
0601202
还没有添加这些自定义字段之前的文章会自动使用文章摘要作为默认 description ,而默认的 keywords 是为空。
061203
typecho的head里输出了很多乱七八杂的东西,很多咱也看不懂,干脆把那些关了得了
可以在主题的header.php中加入以下代码

<?php $this->header('description=&generator=&template=&pingback=&xmlrpc=&wlw=&commentReply=&keywords='); ?>

文章内页og优化

og是一种新的HTTP头部标记,用了Meta Property=og标签,可以让网页成为一个“富媒体对象,就是你同意了网页内容可以被其他社会化网站引用等,管他呢,别人都说og对seo优化挺有用的,那咱也用上,由于这个只对文章好,所以我们先判断页面是否为文章内页,在输出就好了。

<?php if ($this->is('post')) : ?>
    <!--内页seo优化-->
    <meta property="og:locale" content="zh_CN">
    <meta property="og:type" content="article"/>
    <meta property="article:published_time" content="<?php $this->date('c'); ?>"/>
    <meta property="article:author" content="<?php $this->author(); ?>" />
    <meta property="article:published_first" content="<?php $this->options->title() ?>, <?php $this->permalink() ?>" />
    <meta property="og:title" content="<?php $this->title() ?>" />
    <meta property="og:url" content="<?php $this->permalink() ?>" />
    <?php endif; ?>

最后感觉就也差不多了,关于网页速度和搜索的一些优化也总结一下留在这里吧。

DNS预解析

用meta信息来告知浏览器, 当前页面要做DNS预解析:,在页面header中使用link标签来强制对DNS预解析: 即可。
注:dns-prefetch需慎用,多页面重复DNS预解析会增加重复DNS查询次数。
预解析的实现代码:

    <meta http-equiv="x-dns-prefetch-control" content="on">
    <link rel="dns-prefetch" href="//static.q6q.cc">
    <link rel="dns-prefetch" href="//img.q6q.cc">
    <link rel="dns-prefetch" href="//gravatar.q6q.cc">

浏览器渲染与加速

分别针对IE Chrome浏览器的页面渲染和国产浏览器开启极速内核。

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

禁止搜索转码

<meta http-equiv="Cache-Control" content="no-siteapp">
<meta http-equiv="Cache-Control" content="no-transform">
<meta name="applicable-device" content="pc,mobile">
<meta name="MobileOptimized" content="width">
<meta name="HandheldFriendly" content="true">
<meta content="always" name="referrer">

好了,没了,咱也就知道这么多。

结语

感谢访问强仔博客,希望本文对你有所帮助!


  • 上一篇
  • 下一篇
  • 添加评论
    评论(9)
    小赵酱
    小赵酱

    靓仔 效果如何

    强仔
    吾柯
    吾柯

    绿绿粽叶裹吉祥,填满真诚情意长,清清江水龙舟荡,淡淡黄酒解烦忧,端午节日又来到,幸福快乐绕身旁。祝端午节安康。

    强仔啊
    吾柯
    叶开楗
    叶开楗

    其实天很蓝,阴云总要散,其实海不宽,此岸到彼岸,其实梦很浅,万物皆自然,其实泪也甜,祝你心如愿,我的想法很简单,只要你快乐!祝端午节开心!

    强仔啊
    呆哥
    呆哥

    试着弄了 期待效果

    卷风
    卷风

    不错,归我了

    welcome to qiangzai blog