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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Dejavu's Blog

使用 auto-cpufreq 平衡 Linux 性能功耗 哪吒监控面板部署教程 NodeBB 论坛部署教程 Scaleway VPS 安装 Alpine Linux 甲骨文 ARM 实例部署 Gemma 4 模型 Headscale + Tailscale 组建虚拟专用网 在 Linux 上使用 Yubikey OpenPGP 应用 BuyVM VPS 块存储挂载教程 Alpine Linux 服务器配置指南 Alpine Linux 安装 Cloudflared Docker 多容器共享中心数据库 安装 Komari 服务器监控工具 Scaleway VPS 安装 Debian Linux Debian 13 下部署 AsmBB 论坛 使用 Kopia 自动化备份服务器数据 给 Docker 启用 IPv6 支持 Netcup 服务器安装自定义 ISO 镜像 在 Debian 13 上自托管 Mox 邮局 使用 Stalwart 自托管邮局服务 烽火 HG5582A 光猫开启桥接模式 Docker 自托管 Shlink 短链服务 部署 Obsidian LiveSync 实时同步服务指南 我的 2025 年不完全回顾 我的 2025 年度自托管服务报告 Linux 下 Intel 核显驱动配置与硬件加速 Fedora Linux 安装配置记录 2025 年优雅地自托管 RSS 服务 自托管部署 Pocket ID 与 Tinyauth 完全指南 Woodpecker CI 和 Gitea 实现 Hugo 自动部署 Gitea/Forgejo 集成 Woodpecker CI/CD 在 Blinko 中使用 Ollama 作为 AI 供应商 Docker 部署 Gitea/Forgejo Plausible CE 启用城市级地理位置识别 Blinko 开源 AI 知识库 Docker 部署指南 Netcup 免税账号注册及购买服务器全记录 新到手的 Linux 服务器,我这样设置 Docker 自托管 Cloudreve Pro 私有网盘服务 GiffGaff SIM 卡使用体验和注意事项 在 n8n 中使用 Ollama 的本地 LLM 模型 简体中文互联网在变得糟糕吗? 如何低成本申请 S/MIME 证书用于个人邮件服务 迁移到 NameCrane Mail 域名邮箱套件服务 香烟与咖啡 联系我 Now 近况 在 Windows 中使用 Yubikey 的 OpenPGP 应用 Windows 11 IoT LTSC 养老指南 巧用浏览器生成 HAR 文件批量下载所需网页资源 聊聊静态网站的评论系统 在 Hugo 站点中优雅地展示实况照片 使用 snac 部署一个简洁优雅的 ActivityPub 实例 当 25 岁来临的时候 断网的这两年 从 Bitwarden/Vaultwarden 到 KeePassXC 更新日志 也许是 Android 上最好的本地播放器 - 椒盐音乐 2023 半年小结 写一个好玩的 Hugo 货币汇率转换短代码 写一个 Hugo 短代码将不同类别的总字数统计转换为书名显示 海信 Touch Lite 墨水屏音乐阅读器的简单体验 从 Debian 11(bullseye) 无感升级到 Debian 12(bookworm) 使用 GitHub Actions 自动提交 URL 到 IndexNow 批量重写 Git 历史提交记录 使用 cgit 托管小小的也很可爱的 Git 服务器 在 Debian 上使用 stagit 和 Nginx 的简单 Git 服务器 托管简单 Git 服务器的一些尝试 使用 stagit 自托管纯静态 Git 存储库 使用 Docker 快速部署单人 Fediverse 实例 我是如何建立自己的个人博客的? 简单、隐私友好的谷歌分析替代品,Plausible 自托管部署指南 服务器使用 Cloudflare CDN 的最佳实践 甲骨文服务器分配并启用 IPv6 地址 Git 版本控制学习笔记(二) Cloudflare WAF 防护策略简易指南 Mastodon 服务器批量导入自定义表情 低成本自托管 Mastodon 实例简明指南 自托管服务指南──有了服务器可以做什么? 使用 Miniflux + RSSHub 打造个人 RSS 阅读器 构建支持多种 CPU 架构的 Docker 镜像 一个可自托管的静态短链接应用 别了,二〇二二! Duplicacy CLI 进阶使用指南 Duplicacy CLI 备份工具的基本使用 初探 Cloudflare 零信任 - 通过 Docker 部署 Bitwarden 密码管理器 Yubikey 转运日志及上手指南 初探 Cloudflare 零信任 — 通过 Cloudflare Tunnel 搭建 SSH 聊天室 初探 Cloudflare 零信任 - 通过 Cloudflare Tunnel 访问服务 某科学的 PGP 算号指南 版权声明 2022 年的 MacBook Air M1 使用体验及应用推荐 使用 Vercel 和 Supabase 自托管 Cusdis 评论系统 为什么你的搜索引擎不好用? 个人在 Windows 上常用软件清单 macOS 基础开发环境设置指南 在 macOS 上使用 Canokey 的 OpenPGP 应用 提取 Windows UWP 应用商店的安装包以供离线安装 Git 版本控制学习笔记(一) 使用 Notion 管理 GitHub Star 项目 使用 Vercel 免费部署 Giscus 评论系统 将博客评论从 Utterances 无缝迁移到 Giscus
优化 Hexo 网站的永久链接格式
2020-06-07 · via Dejavu's Blog

前言

Hexo 默认的永久链接格式目录层级太复杂,深度太大,不仅不利于 SEO,而且也不美观,本文介绍一下 Hexo 下文章的永久链接优化流程

Hexo 的文章永久链接优化方式主要有两种:

  1. 免插件式

    修改 Hexo 的配置文件的 permalinks 部分,然后在文章 Markdown 文件的 front-matter 字段进行定义

  2. 插件式

    安装 hexo-abbrlink hexo-abbrlink2 插件并配置

打开 Hexo 的配置文件,找到下列字段按照注释修改

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http://example.com  # 带协议的网站地址,如 https://www,dejavu.moe
permalink: :year/:month/:day/:title/	# 预设永久链接格式  
permalink_defaults:      # 默认永久链接
pretty_urls:             # 美化永久链接
  trailing_index: true   # 设置 false 以删除「页面」永久链接结尾的'index.html'部分
  trailing_html: true    # 设置 false 以删除「文章」永久链接结尾的'.html'部分

免插件式

文章结尾带 .html

文章结尾带 .html 更像一个静态网页,如果你更加喜欢这种格式,可以按照下面修改

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://dejavu.moe  # 修改此处为实际的网站地址
permalink: :permalink        # 修改此处
permalink_defaults:
pretty_urls:
  trailing_index: true	# 设置 true 以显示「页面」永久链接结尾的'index.html'部分
  trailing_html: true	# 设置 true 以显示「文章」永久链接结尾的'.html'部分

写文章的时候在 Markdown 文件的 front-matter 部分新增字段 permalink:,然后写上实际的永久链接,比如

title: 优化 Hexo 的永久链接
toc: true
permalink: /posts/hexo-permalinks.html # 举个例子
date: 2020-06-07 23:35:40

此时永久链接格式就是 https://blog.dejavu.moe/posts/hexo-permalinks.html

文章结尾不带 .html

文章结尾不带 .html 更为简洁,如果你更喜欢这种格式,可以按照下面修改

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://dejavu.moe  # 修改此处为实际的网站地址
permalink: :permalink        # 修改此处
permalink_defaults:
pretty_urls:
  trailing_index: false	# 设置 false 以删除「页面」永久链接结尾的'index.html'部分
  trailing_html: false 	# 设置 false 以删除「文章」永久链接结尾的'.html'部分

在文章 Markdown 文件的 front-matter 新增字段 permalink:,然后写上实际的永久链接,比如

title: 优化 Hexo 的永久链接
toc: true
permalink: /posts/hexo-permalinks/ # 注意这部分
date: 2020-06-07 23:35:40

此时永久链接就是 https://blog.dejavu.moe/posts/hexo-permalinks/

建议将字段 permalink: 字段的配置加入 Hexo 文章模板中,这样每次使用 Hexo CLI 命令新建的文章都会自动在 front-matter 中加入 permalink: 字段

打开 Hexo 根目录下的 scaffolds 文件夹中的 post.md 文件,并在 front-matter 部分新增字段 permalink: /posts/

title: {{ title }}
date: {{ date }}
updated:
categories: 
tags:
toc: true
permalink: /posts/

每次新建文章后在 /posts/ 后加上自定义的格式就行了,这里的 /posts/ 就是我想对所有文章的一个固定路径,相当于所有文章都是在 /posts/ 文件夹下,当然也可以把它改成你喜欢的其他的路径,比如 /articles//works/

插件式

优化 Hexo 永久链接格式常用的插件有 hexo-abbrlink hexo-abbrlink2 插件

在 Hexo 根目录打开终端安装插件

# 使用 npm 安装插件
npm install hexo-abbrlink --save
# 使用 yarn 安装插件
yarn add hexo-abbrlink

修改 Hexo 的配置文件的 permalink: 字段,比如

permalink: posts/:abbrlink/  #文章结尾不带 .html

# 或者
permalink: posts/:abbrlink.html  #文章结尾带 .html

然后在 Hexo 的配置文件里增加 hexo-abbrlink 插件的配置

# hexo-abbrlink
abbrlink:
  alg: crc32      #支持crc16和crc32算法(默认crc16)
  rep: hex        #支持dec和hex值(默认dec)
  drafts: false   #(true)Process draft,(false)Do not process draft. false(default) 
  # Generate categories from directory-tree
  # depth: the max_depth of directory-tree you want to generate, should > 0
  auto_category:
     enable: true  #true(default)
     depth:        #3(default)
     over_write: false 
  auto_title: false #enable auto title, it can auto fill the title by path
  auto_date: false #enable auto date, it can auto fill the date by time today
  force: false #enable force mode,in this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had abbrlink.

默认情况下,在新建文章后,abbrlink 插件会自动使用算法生成唯一的永久链接,比如

#crc16 & hex
https://blog.dejavu.moe/posts/66c8.html
# crc16 & dec
https://blog.dejavu.moe/posts/65535.html
# crc32 & hex
https://blog.dejavu.moe/posts/8ddf18fb.html
# crc32 & dec
https://blog.dejavu.moe/posts/1690090958.html

也可以在文章的 front-matter 部分手动填写 abbrlink 字段的值

title: 优化 Hexo 的永久链接
toc: true
abbrlink: hexo-permalinks #注意这部分
date: 2020-06-07 23:35:40

本文的永久链接就为 https://blog.dejavu.moe/posts/hexo-permalinks/ (文章结尾不带 .html)

https://blog.dejavu.moe/posts/hexo-permalinks.html (文章结尾带 .html)

局限性: crc16 算法生成的最大文章数量为 65535,不过这个对绝大多数人都几乎没影响,如果一个 abbrlink 的值已存在,那么它会尝试其他可用的值

hexo-abbrlink2 插件

在 Hexo 根目录打开终端安装插件

# 使用npm安装插件
npm install hexo-abbrlink2 --save
# 使用yarn安装插件
yarn add hexo-abbrlink2

修改 Hexo 的配置文件的 permalink: 字段,比如

permalink: posts/:abbrlink/  #文章结尾不带 .html

# 或者
permalink: posts/:abbrlink.html  #文章结尾带 .html

在 Hexo 的配置文件里增加 hexo-abbrlink2 插件的配置(可选)

# hexo-abbrlink2
abbrlink:
  start: 100 # 启起始文章id,默认为0 ,可以自定义,比如100

默认情况下,在新建文章后,abbrlink2 插件会自动使用算法生成唯一的永久链接,比如

# 默认起始文章id为0的情况下
https://blog.dejavu.moe/posts/1.html
https://blog.dejavu.moe/posts/2.html
https://blog.dejavu.moe/posts/3.html

#自定义文章起始id为100的情况下
https://blog.dejavu.moe/posts/101.html
https://blog.dejavu.moe/posts/102.html
https://blog.dejavu.moe/posts/1033.html

上面的几种方法选一种即可,我更推荐使用 免插件式 方法