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

推荐订阅源

V
Visual Studio Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
博客园_首页
量子位
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
S
SegmentFault 最新的问题
雷峰网
雷峰网
小众软件
小众软件
博客园 - 聂微东
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog

OhYee 博客

小鹏辅助驾驶测评|OhYee 博客 小鹏非支持手机开启自动解锁|OhYee 博客 使用函数计算实现 301 重定向|OhYee 博客 针对 HTML 内容使用 Ant Design 图片弹框|OhYee 博客 博客进程泄露及僵尸进程解决|OhYee 博客 蓝易云服务器体验|OhYee 博客 SSH 调起本地 VSCode|OhYee 博客 【2022 秋招内推】阿里云后端研发工程师|OhYee 博客 使用函数计算获取 IP 地址信息|OhYee 博客 正确获取客户端 IP/HTTP Header 也可能重复|OhYee 博客 评测 Oculus Quest2 及 BigScreen|OhYee 博客 NextJS 热重载保留状态|OhYee 博客 如何优雅地贴 gist 代码|OhYee 博客 Linux 精细化文件权限|OhYee 博客 VSCode 容器开发环境|OhYee 博客 Clash 的不兼容更新排查|OhYee 博客 Zeek 导出 PCAP|OhYee 博客 记一次 ssh 配置问题|OhYee 博客 Git Commit 规范化工具|OhYee 博客 谈谈《星之卡比-探索发现》|OhYee 博客 VSCode 快捷键绑定 Shell 命令|OhYee 博客 ASN.1 语法及 X.509 证书格式解析解析|OhYee 博客 腾讯企业邮箱忽略 MX 记录发信|OhYee 博客 Chrome/Edge 标签组插件|OhYee 博客 【应届内推】阿里云后端研发工程师|OhYee 博客 损坏的 Typecho 备份处理为 JSON|OhYee 博客 VS Code VIM 插件高效使用|OhYee 博客 SSH 正反向代理|OhYee 博客 Let's Encrypt 根证书过期引发的问题|OhYee 博客 OpenWRT 忽略内核依赖|OhYee 博客
Hexo本地搜索及部分SEO优化|OhYee 博客
2017-02-08 · via OhYee 博客

解决本地搜索问题,并且修改了 Next 主题的部分SEO内容,写了一个小插件用于生成 urls.txt 用来给百度主动推送

百度的站内搜索好久没有收录新的页面,站内搜索这个功能还是掌控在自己手里好一点
Next主题本身自带的有 Local Search 功能
当安装 search.xml 生成插件后,可以自动开启搜索功能

试了下发现点搜索后没有用,找了以下发现生成的xml有错误,有的页面内存在 & 等字符,导致 xml 无法正常解析
想了下还是自己修改下吧
hexo-generator-searchdb 是一个比较完善的插件
可以做到提取摘要部分
不过我还想把 tags 部分和 keywords 部分也提取出来用来增强搜索功能

同时这个插件生成的链接存在一些小bug,不知道是不是我哪里设置有问题

自己修改了下

<?xml version="1.0" encoding="utf-8"?>
<search>
  <% if(posts){ %>
    <% posts.slice(0,limit).each(function(post){ %>
    <entry>
      <%
            var dd = "";
            if(post.keywords){
                post.keywords.forEach(function(keyword){
                    dd +=  keyword.name + '|';
                });
            }
            if(post.categories){
                post.categories.forEach(function(category){
                    dd +=  category.name + '|';
                });
            }
            if(post.tags){
                post.tags.forEach(function(tag){
                    dd +=  tag.name + '|';
                });
            }
      %>
      <title><%-: post.title | cdata %></title>
      <url><%- encodeURIComponent(post.path) %></url>
      <content type="text"><%-: dd + (raw ? post[raw] : post.content) | cdata %></content>
    </entry>

    <% }) %>
  <% } %>
  <% if(pages){ %>
    <% pages.each(function(page){ %>
    <entry>
      <title><%-: page.title | cdata %></title>
      <url><%- encodeURIComponent(post.path) %></url>
      <content type="text"><%-: raw ? page[raw] : page.content | cdata %></content>
    </entry>
    <% }) %>
  <% } %>
</search>

本地优化主要在于 <title></title><meta name="keywords" />

<title>{% block title %}{% endblock %} - {{ config.description }} |{% if page.keywords %}{% for keyword in page.keywords %}{{ keyword }}|{% endfor %}{% endif %}{% if page.tags and page.tags.length %}{% for tag in page.tags %}{{ tag.name }}|{% endfor %}{% endif %}</title>
<meta name="keywords" content="{% if page.keywords %}{{ page.keywords }},{% endif %}{% if page.tags and page.tags.length %}{% for tag in page.tags %}{{ tag.name }},{% endfor %}{% endif %}{% if theme.keywords %}{{ theme.keywords }}{% endif %}{% if config.keywords %}{{ config.keywords }}{% endif %}" />