文章加密
Mizuki 主题支持文章级别的密码保护功能,可以为特定文章设置访问密码,保护私密内容。
在文章的 frontmatter 中添加加密相关字段:
---title: 私密文章published: 2024-01-15description: 这是一篇加密文章encrypted: truepassword: "mypassword123"passwordHint: "密码是我的生日"---| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
encrypted |
boolean | ✅ | 设为 true 启用加密功能 |
password |
string | ✅ | 访问密码 |
passwordHint |
string | 可选 | 密码提示,显示在密码输入框下方 |
hideHomeContent |
boolean | 可选 | 是否隐藏公开摘要,默认 true |
---title: 个人日记published: 2024-06-01description: 我的私人日记encrypted: truepassword: "diary2024"passwordHint: "年份 + 日记的英文"hideHomeContent: truetags: [日记, 个人]category: 生活---
这是只有输入正确密码才能看到的内容...加密文章在网站上会显示以下公开信息:
- ✅ 文章标题
- ✅ 发布日期
- ✅ 标签
- ✅ 分类
- ❌ 文章正文内容(被隐藏)
- 访问加密文章时会显示密码输入界面
- 用户需输入正确密码才能查看完整内容
- 密码验证在客户端完成
首页摘要控制
Section titled “首页摘要控制”hideHomeContent 字段控制是否在首页、标签页等列表中显示文章摘要:
# 默认行为:设置 password 后自动隐藏摘要hideHomeContent: true
# 显式允许显示摘要hideHomeContent: false即使 hideHomeContent 设为 false,文章的完整内容仍然需要密码才能查看。这只影响列表中的摘要预览。
个人私密日记
Section titled “个人私密日记”---title: 2024年6月日记encrypted: truepassword: "mydiary6"passwordHint: "我的日记 + 月份"------title: 项目内部文档encrypted: truepassword: "project2024"passwordHint: "项目代号 + 年份"------title: 深度技术分析encrypted: truepassword: "premium"passwordHint: "会员等级"hideHomeContent: false---安全注意事项
Section titled “安全注意事项”- 客户端验证:密码验证在浏览器端完成,技术用户可能通过查看源代码获取内容
- 构建输出:加密内容仍会包含在构建产物中
- RSS 订阅:加密内容不会出现在 RSS 订阅中
- 搜索引擎:加密内容不会被搜索引擎索引
- API 访问:加密内容不会出现在公开 API 响应中
密码管理建议
Section titled “密码管理建议”- 使用有意义且容易记忆的密码
- 善用
passwordHint提供足够的提示 - 避免在公开场合泄露密码
- 定期更换敏感内容的密码
- 不要在源代码仓库中存放敏感密码
- 加密功能仅保护文章正文,标题、日期等元数据仍为公开
- 密码区分大小写
- 加密文章不会出现在搜索结果中
- 加密文章不会生成搜索引擎索引
- 建议将加密文章的
draft保持为false,否则文章完全不可见