前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Typecho关于seo的一些优化

Typecho关于seo的一些优化

作者头像
qiangzai
发布2021-12-21 08:56:27
1.4K1
发布2021-12-21 08:56:27
举报
文章被收录于专栏:强仔博客

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

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

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

代码语言:javascript
复制
    $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
061201

这些都可以在文章内的head里显示

0601202
0601202

还没有添加这些自定义字段之前的文章会自动使用文章摘要作为默认 description ,而默认的 keywords 是为空。

061203
061203

typecho的head里输出了很多乱七八杂的东西,很多咱也看不懂,干脆把那些关了得了 可以在主题的header.php中加入以下代码

代码语言:javascript
复制
<?php $this->header('description=&generator=&template=&pingback=&xmlrpc=&wlw=&commentReply=&keywords='); ?>

文章内页og优化

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

代码语言:javascript
复制
<?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查询次数。 预解析的实现代码:

代码语言:javascript
复制
    <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浏览器的页面渲染和国产浏览器开启极速内核。

代码语言:javascript
复制
    <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">

禁止搜索转码

代码语言:javascript
复制
<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">
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-06-125,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章自定义字段功能设置描述与关键词
  • 文章内页og优化
  • DNS预解析
  • 浏览器渲染与加速
  • 禁止搜索转码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档