I'm experimenting with hugo and this theme. From the example site in the repo i can see, that posts featured images are configured the following way:
featured = "pic.jpg"
featuredalt = "Pic 2"
featuredpath = "date"
which requires me to place pic.jpg
in static/img/YEAR/MONTH
.
Can someone explain me, how this path gets assembled from featuredpath = "date"
? Are there any other options? maybe relative the the source.md file? The templating magic happens here, but there is nothing with date
included.
You're on the right track. You noticed that layouts/post/featured.html
is involved. But notice this line:
{{ partial "img-path" . }}
This means there's partial named img-path
that gets inserted here. So we'll jump over to it. If you look in /layouts/partials/img-path.html
you'll see this comment on line 7:
if path is date then it will format the directory to year/date i.e. 2006/01
Then you see lines 18-24, which create the date-centric image path:
{{ $.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 }}
On a somewhat related note, I've found the Hugo forums valuable for getting quick feedback on questions like these.
Other great resources include blogs (like the one by Régis Philibert and an entry by the Future Imperfect theme's creator) and the Hugo documentation.