SOLVED: How to access a .Site parameter variable directly

In my config.toml file, I have

[author]
    name = "michael d henderson"

I’m trying to pull that in to a partial template but can’t figure out how to pull that in.

<meta name="author" content="{{ .Site.Params.author.name }}">

I’ve tried dumping variables per @natefinch's posting, but can’t figure this one out. I’d appreciate a nudge in the right direction.

Sometimes the best way to answer a question is to just ask it out loud.

<meta name="author" content="{{ .Site.Author.name }}">

No “.Params” in the variable name. I figured this out by creating a partial with @natefinch's print statement:

$ vi layouts/partials/dumpdot.html
{{ printf "%#v" . }}
:wq

When I called {{ partial "dumpdot.html" .Site }}, I noticed that Author was at the top level. A quick update to call {{ partial "dumpdot.html" .Site.Author }} showed me what I was missing and I felt mighty humble.

I want to add that the live reload makes this quick and painless.

Okay, I don’t actually understand this.

My config.toml file has

[[Params.skin]]
		show_generated_by = true

```
My `partials/footer.html` file has
```
<p>//WebSiteCopyright//
{{ if .Site.Params.skin.show_generated_by }}
 &middot; Generated by <a href="http://gohugo.io/" title="A Fast and Modern Static Web Site Engine">Hugo</a>
{{ end }}
&middot; textToVerifyThatThisIsNotEmpty</p>
```
My output has
```
<p>//WebSiteCopyright//
	
	</div>
<script>document.write('<script src="http://'
        + (location.host || 'localhost').split(':')[0]
		+ ':1313/livereload.js?mindelay=10"></'
        + 'script>')</script></body>
```
The `&middot; textToVerify...` and the closing `</p>` are missing, which usually means that the render choked. I don't understand why.

Did you restart hugo server? Changes to config.toml aren’t picked up on the fly, AFAIK.

Yes. The documentation is very clear about restarting.

This works fine here:

[Params.skin]
show_generated_by = true
1 Like

That was the issue. I didn’t notice that I’d picked up [[ and ]] instead of the single brackets.

1 Like