Welcome to Sanhai’s Blogs!
快速开始
根据搜索结果,安知鱼(AnZhiYu) 是一款基于 Hexo 框架的博客主题。要在该主题中添加"最后更新时间"功能,我给你提供以下技术方案:
实现方案
方案一:在文章 Front-matter 中添加更新时间
在每篇 Markdown 文章的头部添加 updated 字段:
Yaml
title: 文章标题
date: 2026-01-01 10:00:00
updated: 2026-05-16 11:30:00 # 最后更新时间
然后在主题配置文件中启用显示:
Yaml
_config.anzhiyu.yml
post_meta:
updated: true # 显示更新时间
方案二:使用 Hexo 自动生成更新时间插件
安装插件
Bash
npm install hexo-generator-update --save
配置插件 在 Hexo 根目录的 _config.yml 中添加:
1 | update_generator: |
修改主题模板 在 themes/anzhiyu/layouts/_partial/post-meta.pug 中添加:
1 | - if post.updated |
方案三:手动修改主题文件显示更新时间
找到文章元信息模板文件
themes/anzhiyu/layouts/_partial/post-meta.pug
添加更新时间代码
1 | // 在已有日期显示代码后添加 |
重新生成博客
1 | hexo clean && hexo g && hexo s |
主题配置示例
在 _config.anzhiyu.yml 中配置:
1 | # 文章元信息 |