+++
title = "title"
description = ""
[[Info]]
date = "2019-04-30"
type = "type"
+++
Is possible to create and get (and how) access to this metadata on .md pages?
+++
title = "title"
description = ""
[[Info]]
date = "2019-04-30"
type = "type"
+++
Is possible to create and get (and how) access to this metadata on .md pages?
Yes. You can access it via .Params.Info.date
etc. Also, if you remove the quotes around the date, it will turn into a proper date time object.
It does not work for me, with
{{ with .Params.Info.date }}<a>{{ . }}</a>{{ end }}
I got
executing "main" at <.Params.info.date>: can't evaluate field date in type interface {}
If I do
{{ with .Params.Info }}<a>{{ . }}</a>{{ end }}
it builds with the output:
[map[date:2019-04-30 type:type]]
but I dont know how to access the individual items.
Iām new to gohugo, is that a syntax from hugo or is it related to GO?
Maybe Params.Info is a list? Try replacing the double square brackets with single ones:
[Info]
Both of us might need to brush up on TOML syntax
You can access it like so:
{{ range .Params.Info }}{{ with .date }}<a>{{ . }}</a>{{ end }}{{ end }}
thanks! I will move on now!