Started building site
ERROR: 2016/11/08 12:07:44 template.go:131: template: theme/_default/li.html:27:33: executing “theme/_default/li.html” at <index .Site.Params.a…>: error calling index: value is nil; should be of type string in theme/_default/li.html
ERROR: 2016/11/08 12:07:45 template.go:131: template: theme/_default/li.html:27:33: executing “theme/_default/li.html” at <index .Site.Params.a…>: error calling index: value is nil; should be of type string in theme/_default/li.html
I believe the index needs to a number; as in, think of the position of an index in an array. You might have better luck (don’t have time to test) with the following:
{{$thisAuthor := .Params.author }}
{{$author := range where .Site.Params.authors "==" $thisAuthor }}
But some of this is conjecture since I’m not sure how your params are set up in your config file.
Also, check out the default function since this might help reduce your if/else statements (just a thought). Cheers.
[params.authors]
[params.authors.jasmine]
name = ""
bio = "Jasmine's passion for writing is fueled by nature and the magic of every day life. Peace, love & truth are the messages that she has to share with others. To see more of her original work, please check out her Instagram."
location = ""
website = ""
email = ""
irc = ""
steemit = ""
twitter= ""
image = ""
instagram = ""
author.html does not give error. but if I use the same line {{$author := index .Site.Params.authors (.Params.author)}}
in my other template file, it gives error. executing “theme/_default/li.html” at <index .Site.Params.a…>: error calling index: value is nil; should be of type string in theme/_default/li.html
This gives error, this is inside of recent_articles.html. Same line as author.html {{$author := index .Site.Params.authors (.Params.author)}} but author.html does not give error.
this file gives error. Why is the same code giving error in one place, and not in another?
this would come from the article front matter, right?
+++
author = "jasmine"
authors = "jasmine-miller"
categories = ["Authors"]
date = "2016-11-03T23:55:33-06:00"
description = "This poem and photo were inspired by a combination of Cannabis and meditation."
google_news_keywords = [""]
og_audio = ""
og_image = "https://i.imgur.com/tF1VFsY.jpg"
og_image_url = "https://i.imgur.com/tF1VFsY.jpg"
og_video = ""
tags = ["Poetry"]
title = "Solitude And Grace - An Original Poem By Jasmine Miller"
+++
It’s set.
{{$author := index .Site.Params.authors (.Params.author)}}
If I use this code in /partials/author.html, I get no errors.
If I use this code in /partials/recent_articles.html, I get this error.
The .Params.author from article front matter is specified. The config.toml .Site.Params.authors is also specified.
Just to qualify, you are using both these partials in page and not node/list types layouts, yes? If you’re using the recent... partial in a node, it doesn’t have front matter to pull from. Again, just conjecture.