Hugo 的一些设置

Hugo 页面提示 raw HTML omitted

从 Wordpress 转移到 Hugo 因为原文章内容带 html,转为 Hugo 后页面不显示内容,审查元素提示 <!-- raw HTML omitted -->,这个是因为 Hugo 的 markdown 安全保护,在 hugo.toml 里添加下面代码就好了:

[markup.goldmark.renderer]
  unsafe = true

Hugo 为新建内容预设模板

通过 hugo new content 命令创建的内容时,可以在 Archetypes 目录下预设模板,使创建的内容自带预设置好的 front matter 信息。

Archetypes 模板起效果的优先等级顺序从上到下为:

  • archetypes/posts.md
  • archetypes/default.md
  • themes/my-theme/archetypes/posts.md
  • themes/my-theme/archetypes/default.md

如果都没设置,则是由 hugo 自动生成。

一般上述文件内容为:

---
date: '{{ .Date }}'
draft: true
title: '{{ replace .File.ContentBaseName `-` ` ` | title }}'
---

可以根据主题实际情况再往里面加 categoriestagsfront matter 信息。

换色
阅读
登录
扫码