Build Websites with Hugo: page 52 Your Turn item 3

  1. Incorporate the social media links into your site’s footer. Include the code in a partial.

I’m stuck and I think it’s a scoping issue.
I pasted the ul block from contact.html into a partial I call social.html

<ul>
  {{ range .Site.Data.socialmedia.accounts }}
    <li><a href="{{ .url }}">{{ .name }}</a></li>
  {{ end }}
</ul>

social.html is getting picked up in the footer.html partial

<footer>
    <small>Copyright {{now.Format "2006"}} {{ .Site.Params.author }}. {{partial "social.html"}}</small>
</footer>

but is just rendering a blank unordered list in the output source

<footer> <small> Copyright 2021 Brian Hogan. <ul></ul> </small> </footer>

I think I got it. Here’s footer.html

{{ $links := .Site.Data.socialmedia.accounts }}
<footer>
    <small>Copyright {{now.Format "2006"}} {{ .Site.Params.author }}. {{partial "social.html" (dict "links" $links)}}</small>
</footer>

Here’s social.html

<ul>
  {{range .links}}
  <li><a href="{{ .url }}">{{ .name }}</a></li>
  {{end}}
</ul>

I am curious how it might be done without the dict function.