Hugo Theme with" featuredpath"

时间:2018-05-05 23:09:21

标签: hugo static-site

我正在试验hugo和this theme。从回购中的示例网站我可以看到,帖子特色图像的配置方式如下:

featured = "pic.jpg"
featuredalt = "Pic 2"
featuredpath = "date"

要求我在pic.jpg中放置static/img/YEAR/MONTH。 有人可以解释一下,这条路径是如何从featuredpath = "date"收集的?还有其他选择吗?也许相对于source.md文件?模板魔法发生here,但没有包含date的内容。

1 个答案:

答案 0 :(得分:1)

你走在正确的轨道上。您注意到layouts/post/featured.html涉及到了。但请注意这一行:

{{ partial "img-path" . }}

这意味着会在此处插入部分名为img-path的名称。所以我们会跳到它。如果您查看/layouts/partials/img-path.html,您会在第7行看到此评论:

 if path is date then it will format the directory to year/date i.e. 2006/01

然后你会看到第18-24行,它们创建了以日期为中心的图像路径:

{{ $.Scratch.Set "path" "/img/" }}
{{ if eq $structType "shortcode" }}
  {{ $.Scratch.Add "path" (.Page.Date.Format "2006/01") }}
{{ else }}
  {{ $.Scratch.Add "path" (.Date.Format "2006/01") }}
{{ end }}

在一个有点相关的说明中,我发现Hugo forums对于快速反馈这些问题很有价值。

其他优秀资源包括博客(例如Régis Philibertentry by the Future Imperfect theme's creator)和Hugo documentation