Is it possible to have Hugo download remote images and serve them as a static file when the site is built?
I have a data/people/
directory which contains one file for each person I want to display, for example:
nickname: copygirl
buttons:
- website: https://example.net/
- twitter: koppeh
- github: copygirl
about: "Just an example"
I’m displaying these somewhat like so:
<ul class="boxes">
{{ range $name, $person := .Site.Data.people }}{{ with $person }}
<li><div>
<h3 class="nickname">{{ .nickname }}<h3>
<img class="picture" src="/images/people/avatars/default.png" />
[...]
</div></li>
{{ end }}{{ end }}
</ul>
If /images/people/avatars/{{ $name }}.png
doesn’t exist already, but the twitter
field does, I would like to download it from https://twitter.com/{{ .twitter }}/profile_image?size=original
each time the site is built, without being cached in-between separate site builds (or at least not for long). I could then also set up the site to rebuild periodically (as well as from a git push) to get the most recent avatar for each person.
Is there any way to do this with Hugo? If not directly possible, where could I hook an external script into to generate / output additional resources?
edit: Forgot to mention: Additionally, it would be nice to be able to resize the image so I can have an icon-sized version of the avatar.
Thanks for your time!