LinMinquan's Blog

Experience technology to change life

Hugo, Front Matter Variable, Type

Hugo V40.2

Hugo 的 Front Matter Variable 有一个是 Type,它的默认值是这篇 post 所在的 directory ,如果这篇 post (假设文件名为 aaa.md ) 所在的目录是 blog ,那它最终的 url 是 xxx.com/blog/aaa/ ,而 Type 可以修改其中的 blog 为其它字符。

我遇到的问题是我的 posts 都是从网站(基于 WordPress )上用插件导出来的,这样每个 post (markdown file) 里的 Front Matter 会有 Type: posts 的属性。有这个设置使得这些 posts (markdown file) 的 template 是基于 posts template ,但这些 posts (markdown file) 其实是放在 blog 目录下的,按照我原来的理解,放在 哪个目录下(例如 blog ),其 template 是基于哪个 template 的(放在 blog 下,就基于 blog template )。但其实这个是可以被 type 这个 Front Matter 给 override 的。

解决办法就是把 Type: posts 都删掉,或者修改这些 markdown file 所在目录的文件名。


Share