Hexo-引用自己的文章

文章名称不需要后缀名[1]

1
{% post_link 文章名称 %}

1
{% post_link Hello-World %}

文章链接配置位于 _config.yml 中 permalink[2]

1
2
3
4
5
6
7
8
9
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :title/ # :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks

  1. Hexo 官方 tag plugins 文档说明,post_link 用于插入文章链接,语法按文章文件名定位目标文章;同一文档还说明 post_link / post_path 会忽略 permalink、folder、language 和 date,因此这里的“文章名称”应理解为文章文件名,不需要写 .md 后缀:https://hexo.io/docs/tag-plugins↩︎

  2. Hexo 官方 permalinks 文档说明,permalink 用于配置文章最终 URL 结构;configuration 文档也把 urlrootpermalinkpermalink_defaults 列为站点配置字段。因此文章内链应表达文章身份,最终 URL 形态交给 _config.yml 中的 permalink / url / root 配置生成:https://hexo.io/docs/permalinkshttps://hexo.io/docs/configuration↩︎