Carpintonto

Carpintonto

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>

First Post!

Carpintonto

Carpintonto

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.

Where Next?

Popular Pragmatic Bookshelf topics Top

rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New
dachristenson
I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New

Other popular topics Top

PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New

Sub Categories: