分类 Typecho 下的文章
阿里云虚拟主机使用 Typecho 1.1 开启HTTPS后无法登陆后台
解决方法:
编辑var/Typecho/Request.php,在isSecure方法中追加两个判断条件即可:
|| (!empty($_SERVER['HTTP_X_CLIENT_SCHEME']) && !strcasecmp('https', $_SERVER['HTTP_X_CLIENT_SCHEME']))
|| (!empty($_SERVER['REQUEST_SCHEME']) && !strcasecmp('https', $_SERVER['REQUEST_SCHEME']))
阿里云虚拟主机使用 Typecho 1.1 开启伪静态后打开子页面报错
官方推荐规则在其他环境使用完全正常,到阿里云虚拟主机这就不行了 ┑( ̄Д  ̄)┍
删掉后面的 $1 last就好了
location / {
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}
Typecho使用国内的Gravatar头像源
修改为国内的Gravatar头像源可以大幅提高头像加载速度,在 index.php
或者 config.inc.php
的顶部加入此代码即可
define('__TYPECHO_GRAVATAR_PREFIX__', 'https://cdn.v2ex.com/gravatar/');
20220520更新:
突然发现之前的头像源部分网络无法访问了,可以更换为https://sdn.geekzu.org/avatar/
Typecho链接在新窗口打开
编辑 /var/HyperDown.php,将 <a
全部替换为 <a target="_blank"
即可
Typecho默认主题移动端设备显示搜索框
Typecho的默认主题只在PC端显示,移动设备是不显示搜索框和侧边栏的
修改方法:
打开header.php,将原文的
<div class="site-name col-mb-12 col-9">
<?php if ($this->options->logoUrl): ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>">
<img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>" />
</a>
<?php else: ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title() ?></a>
<p class="description"><?php $this->options->description() ?></p>
<?php endif; ?>
</div>
<div class="site-search col-3 kit-hidden-tb">
<form id="search" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
<label for="s" class="sr-only"><?php _e('搜索关键字'); ?></label>
<input type="text" id="s" name="s" class="text" placeholder="<?php _e('输入关键字搜索'); ?>" />
<button type="submit" class="submit"><?php _e('搜索'); ?></button>
</form>
</div>
修改为
<div class="site-name col-mb-12 col-tb-8 col-9">
<?php if ($this->options->logoUrl): ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>">
<img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>" />
</a>
<?php else: ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title() ?></a>
<p class="description"><?php $this->options->description() ?></p>
<?php endif; ?>
</div>
<div class="col-mb-12 col-tb-3 col-3">
<div class="site-search col-mb-6 col-tb-12 col-12" style="margin-left:25%;">
<form id="search" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
<label for="s" class="sr-only">搜索关键字</label>
<input type="text" id="s" name="s" class="text" placeholder="输入关键字搜索"/>
<button type="submit" class="submit">搜索</button>
</form>
</div>
</div>
Typecho取消隐藏默认主题手机端侧边栏
编辑 /usr/themes/default/sidebar.php 文件,删除第二行的 kit-hidden-tb
即可。
侧边栏没有针对手机端的优化,但如果不显示出来就要另外加个分类页,个人认为还是显示出来好些。
使用TpCache插件为Typecho开启缓存
Typecho文章列表自动输出摘要
typecho默认输出文章是全文输出的,如果想要摘要输出需要手动在文章中添加<!--more-->
改为自动摘要只需将模板文件中的index.php
和archive.php
中的
<?php $this->content('- 阅读剩余部分 -'); ?>
修改为
<?php $this->excerpt('180'); ?>
180为摘要输出字数