ramlife

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

hugo 官方

配置

  • 建议使用 yaml 格式的配置文件。
  • 从 0.110.0 开始,建议使用 hugo.toml 来代替 config.toml
  • 可以使用 config 文件夹来代替 config.toml 这个单文件。注意文件夹里面的文件不是随便的,建议只分为 hugo.yaml, languages.yaml, menus.yaml, params.yaml 这几个。分的多了,hugo 会不认,比如 profileMode 如果单独分为一个文件,就不认,写到 params.yaml 或者 languages.yaml 里面就认了。。。
  • hugo server 是 dev 模式,只会调用 config 下面的 _default/config.toml; hugo 是 build 模式,会调用 _default/config.tomlproduction/config.toml; 当然也可以指定模式, hugo --environment staging 会调用 _default/config.tomlstaging/config.toml。当然在 0.110.0 之后,可以把 config.toml 改为 hugo.yaml.

参考:
Configure Hugo
https://gohugo.io/getting-started/configuration/#all-configuration-settings

PaperMod 主题

Features

官方: https://adityatelange.github.io/hugo-PaperMod/posts/papermod/papermod-features/
中文翻译: https://note.ftls.xyz/papermod/posts/papermod/papermod-features/

  • Archives Layout不支持多语言月份翻译
  • 如果希望某些文章不会被搜索到,在开头添加 searchHidden: true
  • 搜索仅适用于当前语言,用户当前使用的语言 !
  • [draft] 表示草稿
  • 如果特定文档不需要面包屑导航,那么需要在文章开头添加 ShowBreadCrumbs: false
  • editPost 这个功能是 添加一个按钮,通过使用帖子的文件路径链接到编辑目标来建议更改。这个功能使用的前提是源文档需要放在网上,并且是公开的,才能让链接跳转过去,进行修改,一般是 github 上面的公开项目才能这样使用。如果是自己的私人 blog 不建议使用这个功能。
  • 如果单个文章是多个作者,可以在文档开头添加 author: ["Me", "You"]

faq

增加 head,css 等

  • 增加 head,只需要在 layouts/partials/extend_head.html 增加, papermod 会把这个文件中的添加到自己的 head 内。
  • 增加 css,需要在 assets/css/extended/ 文件夹下面添加自定义的 css 即可。

参考:
FAQs
https://github.com/adityatelange/hugo-PaperMod/wiki/FAQs#custom-head--footer
https://adityatelange.github.io/hugo-PaperMod/posts/papermod/papermod-faq/#custom-head--footer

其他配置

  • 不要使用 pygmentsUseClasses: true 来给代码等设定风格,直接使用 pygmentsStyle = "pygments" 这样的配置就可以了。 比较推荐的是 monokai 这种风格。 可选的在这里看 https://xyproto.github.io/splash/docs/all.html
  • Permalinks 如果设置了不起作用,检查是否空格忘了,或者文章本身没有时间等等。
  • config 中的 title 是左上角的标题,param 中的 label 如果设置了,就会替代掉title。
  • content/posts 这一层级是默认的 sections,如果有深层次的目录也希望是 sections,那么这个目录必须包含一个 _index.md 文件。

参考:
pygmentsUseClasses = true not generating classes
https://discourse.gohugo.io/t/pygmentsuseclasses-true-not-generating-classes/15080

Chroma Style Gallery
https://xyproto.github.io/splash/docs/all.html

[SOLVED] How to setup permalinks for all pages?
https://discourse.gohugo.io/t/solved-how-to-setup-permalinks-for-all-pages/14340

Permalinks Configuration Example
https://gohugo.io/content-management/urls/#permalinks-configuration-example

Content Sections
https://gohugo.io/content-management/sections/

使用

多层目录使用自定义的模板

hugo new --kind posts/mix posts/mix/123456.md
上面的意思是 使用 archetypes/posts/mix.md 作为模板来生成 content/posts/mix/123456.md 这个文件。 注意: 模板一定不能加后缀,否则会找不到。。。

参考:
Maximizing the convenience factor: archetypes in Hugo
https://cloudcannon.com/blog/maximizing-the-convenience-factor-archetypes-in-hugo/

Archetypes
https://gohugo.io/content-management/archetypes/

Archetypes
https://www.gohugo.org/doc/content/archetypes/

Archetypes
https://gohugobrasil.netlify.app/content-management/archetypes/

posted on 2023-01-30 18:55  ramlife  阅读(300)  评论(0编辑  收藏  举报