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

jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=&gt; (create-migration "guestbook") Execution error (Ill...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
hazardco
On page 78 the following code appears: &lt;%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
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
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New

Other popular topics Top

dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
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
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
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

Sub Categories: