{{ $baseurl := .Site.BaseURL }}
...
{{ with .Params.images }}{{ range first 6 . }}<meta property="og:image" content="{{ if in . "http" }}{{ . }}{{ else }}{{ $baseurl }}{{ . }}{{ end }}" />
{{ end }}
… but combining them is proving to be a challenge. I tried to include {{ if in $i "http" }}{{ $i }}{{ else }}{{ $baseurl }}{{ $i }}{{ end }} but it makes a mess, with index numbers flying all over.
Thanks again @bjornerik. I tried updating using brew, but, it did not work well, so, I took the previous advice of installing via go get, which I had not tried yet. Had to set a couple of variables in my .zshrc, but once I set the $GOPATH and put $GOPATH/bin in my system path, it ran just fine.
However, now I get many errors on the console like this one:
ERROR: 2015/05/11 template: partials/seo-schema.html:130:46: executing "partials/seo-schema.html" at <$.Site.Params.ISO860...>: invalid value; expected string in partials/seo-schema.html
There is nothing in the latest Hugo comits that should change any of this … but those date format constructions (my guess builtins), looks funky … Will have a look at it later. Norway is on early evening time …
Hmmm… mystery, looks like it doesn’t like ISO8601 as key (it works if you change it to foo or similar) … but that has worked before, and is in use by many…
Thanks for all this @bjornerik. Haha, before I saw your last post about the rollback, this AM I was experimenting around trying to document some observations and hopefully fix the problem.
I tried changing the config.toml variable name to ISOEIGHTSIXOHONE to see if having the numbers in it made a difference. It didn’t (with the original breaking commit). Then I switched the code in my templates to have the date format entered directly like "2006-01-02T15:04:05JST". That worked & no errors on the console. Then I tried the new function in "image" : {{ apply .Params.images "absURL" "." }}, and it worked, so long as I had the date formats in directly.
Then I saw your post about the rollback, so, I did a go get -u github.com/spf13/hugo, put the date formats back to using the variable from config.toml, and yes, I confirm it works.
Thanks for your work. It’s a really nice new feature that makes it easy to address the situation I had been trying to rectify.
ERROR: 2015/05/29 template: partials/seo-schema.html:22:17: executing "partials/seo-schema.html" at <apply $.Site.Data.ge...>: error calling apply: called apply using interface {} as type string in partials/seo-schema.html
This however works:
"image" : [ {{ range $i, $e := $.Site.Data.general.images }}{{ if $i }}, {{ end }}{{ $e | absURL }}{{ end }} ]
I’m just wondering why the original construction you taught me does not work for a data file. Just trying to wrap my head around it.
I was trying to mimic the image array I had in posts, for a page like the home page, by supplying a generic list of images for the site, in a data file. I’ll try some other formats.