Cannot get .Site.Params.link at <footer>

config.yaml

param:
  link:
    - name: github
      url: 
    - name: linkedin
      url: 

footer.html

        {{- range .Site.Params.link  }}
        {{- if .Name }}
        test
	    {{- end }}
        {{- end }}

It’s weird that nothing is printed. Plz help me figure it out. :wink:

Two problems.

Change this:

param:
  link:
    - name: github
      url:
    - name: linkedin
      url:

to this:

params:  # plural
  link:
    - name: github
      url:
    - name: linkedin
      url:

And change this:

{{- range .Site.Params.link  }}
{{- if .Name }}
test
{{- end }}
{{- end }}

to this:

{{- range .Site.Params.link  }}
{{- if .name }} 
test
{{- end }}
{{- end }}

Thanks for your help but it still didn’t work. :joy:

Then you have a different problem, and need to share all of your code, not just excerpts.

See https://discourse.gohugo.io/t/requesting-help/9132.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

I’m new to hugo and trying to create a hugo theme from scratch here.

You didn’t pass any context to the partial.

In themes/three4th/layouts/_default/baseof.html, change this:

{{- partial "footer.html"}}

to this:

{{- partial "footer.html" . }}

Alternatively, since the footer currently doesn’t require access to anything other than site variables, you could use the site function instead of accessing the site variables via context. Change this:

{{- range .Site.Params.link }}

to this:

{{- range site.Params.link }}
1 Like

Thanks very much. That’s help me a lot.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.