Maps in front matter?

Is it possible to have maps in front matter?

I’m looking to define an collection of images (or anything else) and give it properties for title, description, src, etc.

Is this possible?

I’m not sure which front matter you use, but what you’re looking for is pretty easy. @natefinch uses it in his npf source for code badges, and I adapted that in my config.toml for social sites:

  [[params.social]]
    icon = "tumblr"
    site = "Tumblr"
    url = "http://halostatue.tumblr.com/"
    user = "halostatue"

  [[params.social]]
    icon = "youtube"
    site = "YouTube"
    url = "https://www.youtube.com/user/halostatue"
    user = "halostatue"

I was thinking on a per page basis. I wanted to basically define an image gallery. For now I’ve included (optionally) Lightbox and just manually code the anchor and image elements to use Lightbox. I thought it would have been nice to range over a set, but I’m wondering if that’s getting more complex than needed. Or no more complex than manually writing some HTML.

It’s the exact same code regardless of if it’s in the config or in the front matter.

You access it slightly differently because they are stored in different locations. Per page is actually easier.

How come I can’t directly access (using the example above):

.Site.Params.social.icon

?? I seem to have to range over .Site.Params.social to print out .icon

It would be great to just be able to specify single string values in config.toml and access them directly, without specifying a map.

You can: Configure Hugo | Hugo, the reason @halostatue exemplified a table was because you asked for it.

Yea, it just doesn’t seem to work for me. I can’t access things I set in the config like that. I’ve had luck with specifying a map and use range. That’s about the only way I’ve seen data come out of .Site.Params

Then you’re doing it wrong :slight_smile:

config.toml:

[params]
test1 = "foo"

index.html:

{{ .Site.Params.test1 }}

Ah, I see. Cool, seems to work a little better now. Though I can’t say if or if isset. At least I can print out the value though.

strike that – some sort of cache or something weird. all good =)