惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

记录生活,精彩一刻 - typecho

Typecho 插件推荐 UploadPlugin Typecho-Riven主题正式发售啦 Typecho 已经更新到1.3.0 ,你更新了吗? 分享一个适用于Typecho博客的Robots协议规则 推荐一款特别漂亮的Typecho主题 - 见字 Typecho插件:ImageAccelerator文章图片加速 Typecho开启Gzip压缩加速网站 Typecho 数据库字符集导致Emoji表情评论报错 Typecho 博客自定义右键 Typecho 网站更换域名操作指南 Typecho发布文章时出现的错误
Typecho 站内搜索插件 SiteSearch(BUG)
Huo · 2026-06-13 · via 记录生活,精彩一刻 - typecho

今天早上醒的特别早,也睡不着了,躺着也没啥意思,起来捣鼓博客吧,自从主题及系统升级完后一直还没测试过站内搜索的功能,尝试一下,结果发现问题,这篇文章做个记录。

这个问题不一定其它朋友遇到,但是我是真遇到了,这个博客永久链接地址设置了自定义地址 /archives/{slug}.html 。

搜索完成后,地址链接错误,给出的链接地址还是 https://9sb.net/archives/{slug}.html 不是真实的文章链接地址,随后找 AI 解决一下。

找到插件目录Action.php文件,找到原代码:

    private function formatResult($post, $matchType, $snippet = null)
{
    // 根据类型生成正确的URL
    $type = $post['type'];
    $cid = $post['cid'];
    $slug = isset($post['slug']) ? $post['slug'] : '';
    
    if ($type === 'page') {
        // 独立页面使用slug生成URL
        $url = Typecho_Router::url('page', array('cid' => $cid, 'slug' => $slug));
    } else {
        // 文章使用默认路由
        $url = Typecho_Router::url('post', array('cid' => $cid));
    }
    
    $result = array(
        'title' => $post['title'],
        'url' => $url,
        'date' => date('Y-m-d', $post['created']),
        'matchType' => $matchType,
        'contentSnippet' => $snippet
    );
    
    return $result;
}

直接更换为:

    private function formatResult($post, $matchType, $snippet = null)
{
    $type = $post['type'];
    $slug = isset($post['slug']) ? $post['slug'] : '';
    $siteUrl = rtrim(Helper::options()->siteUrl, '/');

    if ($type === 'page') {
        // 独立页面沿用系统原生路由
        $url = Typecho_Router::url('page', array('cid' => $post['cid'], 'slug' => $slug));
    } else {
        // 文章强制适配自定义永久链接 /archives/{slug}.html
        $url = $siteUrl . '/archives/' . htmlspecialchars($slug) . '.html';
    }

    $result = array(
        'title' => $post['title'],
        'url' => $url,
        'date' => date('Y-m-d', $post['created']),
        'matchType' => $matchType,
        'contentSnippet' => $snippet
    );
    
    return $result;
}

然后再去测试,问题已经解决,OK 收工。