Typecho 其实自带了 RSS 订阅,链接应该是 /feed,不过这个 RSS 不符合 Feed Validation Service 标准,有些 RSS 阅读器可能无法正确显示订阅或者内容。

搜索后找到 CustomRSS 插件,作者:云心怀鹤 | Github

启用插件,RSS 生成的地址是 /rss.xml

如果遇到生成的链接是 /{category}/xxxxxx.html 的问题,根据作者回复评论中的解决办法 (链接):

打开插件的 Plugin.php,修改以下

// $permalink = Typecho_Router::url('post', $row, $options->siteUrl);
$permalink = Typecho_Router::url('post', $row, $options->index);

然而,该办法在我的主题中并不生效,AI 的解决办法如下:

同样是 Plugin.php 文件,找到以下这一行:

$permalink = Typecho_Router::url('post', $row, $options->siteUrl);

在其之前添加:

$categories = $db->fetchAll($db->select()
    ->from('table.metas')
    ->join('table.relationships', 'table.metas.mid = table.relationships.mid')
    ->where('table.relationships.cid = ?', $row['cid'])
    ->where('table.metas.type = ?', 'category'));

if (!empty($categories)) {
    // 使用数组第一个分类的 slug
    $row['category'] = $categories[0]['slug'];
}

保存后在网站根目录删掉 rss.xml 文件,如果有套 CDN 可能需要清理一下缓存,重新访问 /rss.xml 链接两次以使插件重新生成 RSS,链接就正常了。

Screenshot 02-12 at 18.54.10@2x

标题:为 Typecho 博客添加 RSS 订阅链接

日期:2025-02-12

链接:https://logs.do/logs/add-rss-subscription-to-typecho-blog.html

许可:© CC BY 4.0 · 转载请保留原文链接及作者

标签: typecho

添加新评论