Typecho博客优化记录

蓝调 2020-12-28 PM 1442℃ 2条

u=3087675103,3300994286&fm=26&gp=0.jpg

1.开启HTTPS

Typecho安装成功后如果开启https将会无法访问管理后台,需要进行以下操作

1)修改配置文件:编辑Typecho站点根目录下的文件config.inc.php加入下面一行配置

    /** 开启HTTPS */
define('__TYPECHO_SECURE__',true);

2)强制开启https:将下方代码添加到Ningx配置文件里面去

  server
{
        listen 80;
        server_name domain.com www.domain.com;
        rewrite ^(.*) https://domain.com$1 permanent;
}

3)如果开启https后无法评论,可能是开启https后评论action的地址还是http,所有需要改一下评论文件的Form 提交的action的地址,找到主题的评论文件,一般是comments.php ,在里面搜索$this->commentUrl()
修改为,然后保存即可

echo str_replace(“http”,“https”,$this->commentUrl());

2.更换主题

目前使用的是主题Typecho Theme RAW,链接:https://github.com/AlanDecode/Typecho-Theme-RAW
目前使用的是主题echo,作者网站:点我跳转

3.更换编辑器

用来替换原有的markdown编辑器。markdown虽然好用,但是一些表单等格式不支持,不适合编辑博客。方法:
> 在撰写设置中关闭:使用markdown语法编辑和解析内容
> 访问https://github.com/chanshengzhi/UEditor-for-Typecho,按照页面提示“安装方式1:
> 在线安装” 去插件中心启用UEditor
经过简单的折腾,还是换回默认的markdown(仅用了2个小时,还是markdown香)
增加了EditorMD 插件 github地址:https://pandao.github.io/editor.md/

4.echo主题优化

目前发现的bug:echo主题文章的缩略图只能是本地上传的图片,图床的无效,目前还没有找到解决办法

5.插件安装

5.1 CodePrettify高亮代码-github项目地址
演示如下

if (typeof Prism !== 'undefined') {
var pres = document.getElementsByTagName('pre');
                for (var i = 0; i < pres.length; i++){
                    if (pres[i].getElementsByTagName('code').length > 0)
                        pres[i].className  = 'line-numbers';}
Prism.highlightAll(true,null);}

5.2 评论区表情-github项目地址Smilies表情插件

5.3 热门文章--http://www.molerose.com/archives/24/
https://plugins.typecho.me/bytecats3/plugins/tepostviews.html
Sitemap
注:目前并不太合适,需要优化

5.4视频引用插件-github项目地址
使用方法:
默认不自动播放,弹幕不开启

[#dplayer url="http://xxx.com/xxx.mp4" pic="http://xxx.com/xxx.jpg"/]

开启弹幕

[#dplayer url="http://xxx.com/xxx.mp4" pic="http://xxx.com/xxx.jpg" danmu="true"/]

开启自动播放

[#dplayer url="http://xxx.com/xxx.mp4" pic="http://xxx.com/xxx.jpg" autoplay="true"/]

注:上述代码复制时删除#

以下为测试视频

5.5 typecho站点统计插件-

5.6sitemap
暂不开启,不需要收录

5.7 底部悬浮音乐播放器插件QPlayer-github项目地址

6.开启伪静态

  if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
}

7.修改页面字体
在theme主题下的CSS/style css 下查找font-family修改需要的字体,推荐的字体如下:

font-family:"Source Sans Pro", "Hiragino Sans GB", "Microsoft Yahei", SimSun, Helvetica, Arial, sans-serif, monospace;

8.增加文章页面编辑功能
在主题目录下的post.php增加以下代码

        <div class="edit">
            <?php if($this->user->hasLogin()):?>
                <a href="<?php $this->options->adminUrl(); ?>write-post.php?cid=<?php echo $this->cid;?>" target="_blank">编辑</a>
            <?php endif;?>
        </div>

[7]正文页面增加编辑功能https://maomao.ink/index.php/web/312.html

标签: 博客优化

非特殊说明,本博所有文章均为博主原创。

评论啦~


icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif

已有 2 条评论


  1. Vica
    Vica   Windows 10 x64 Edition Google Chrome 84.0.4147.125

    icon_cry.gif 主题echo链接打不开了,能打包一份吗?

    回复 2022-06-29 08:20
    1. 蓝调
      蓝调 博主   Windows 10 x64 Edition Google Chrome 103.0.0.0

      https://www.ncc.wang/ 作者网站换了在这里,然后github也有,在这里https://github.com/ncccode/echo。我的是2.0的,现在已经是3.0

      回复 2022-07-18 12:24
Title - Artist
0:00