{{ with .Site.GetPage "home" }}{{ .Title }}{{ end }} returns an empty result (incorrect) while {{ with .Site.GetPage "page" "_index.md"}}{{ .Title }}{{ end }} generates an error.
Your first construct is correct. Note that there is a shortcut in {{ with .Site.Home }}
As to why you get an empty .Title, that is hard to tell from the little you show us (is there a title in the _index.md file?). Do you have a link to the source?
As an aside using {{ (.Site.GetPage "home").Date }} returns 0001-01-01 00:00:00 +0000 UTC rather than the date specified within _index.md, perhaps the file is being ignored?
For reference this has been tested on Ubuntu 16.04 LTS with Hugo 0.31 (http://localhost:1313).
Appreciate the update though executing hugo server -v doesn’t report any relevant error/warning.
Unfortunately the issue doesn’t occur when creating a simple example site so we’ll try and locate the cause systematically and report here for completeness.
After further testing it appears the issue was caused by an empty taxonomy value within config.toml, despite no error or warning being generated (hugo server -v):
[taxonomies]
author = ""
category = "categories"
tag = "tags"
No. Don’t know how this was the culprit for your problem.
I just tested what you wrote above because I regularly use empty taxonomies in my projects. The reason being I take advantage of Hugo’s taxonomies for internal purposes without exposing unnecessary URLs.
And I am able to get the homepage title in permalink pages by calling it in the single pages template at /layouts/_default/single.html while having an empty taxonomy in my config.
In which template have you tried to get the title and failed?
Line 12-16 of themes/minimo/layouts/partials/nav/menus/main.html was customized to highlight the problem at the top of every page, commenting-out author within config.toml resolves the issue and should successfully display the title of _index.md.
This looks more like a Minimo theme bug than a Hugo bug. Since I cannot reproduce it with a custom theme that I’m using.
It does happen in your project of course. And I did try placing the snippet in different parts. It fails every time unless of course the empty taxonomy is either removed or filled in.
This shouldn’t be the case.
Maybe you should raise this issue with the Minimo theme creator @MunifTanjim or try a different theme.
No. My config pretty much has what you have. Except for uglyURLs = true Adding this didn’t replicate your issue. Also note that currently I’m on the latest Hugo 0.31.
Try a different theme and see what happens. My theme is a modified version of the Cactus theme
Aha! I finally figured out what’s going on. And it’s not a Minimo theme issue.
Front matter from _index.md is not picked up when a taxonomy is left blank in config.toml
In my project I didn’t use an _index.md and adding one I was able to replicate your issue.
Turns out that you were spot on from the start @mimattr
So as a second fix, if you really need a blank taxonomy just don’t use an _index.md for your homepage. Don’t think you really need one anyway. You can simply replicate it’s front matter as parameters in your config.toml and then call them in your index.html template.
But this issue is probably something for @bep to look at. Since it looks like a Hugo bug.
Can you elaborate on which parts of the setup are ambiguous regarding the source code provided? It was only created as a simple example though has already proven to affect 2 separate sites.
If this is a limitation Hugo should definitely log an ERROR/WARN, silent failures are not particularly useful for anyone.
Home page vs the empty taxonomy term resolves to the same place on the file system. You could try to disable the taxonomyTerm kind. We have an issue to handle this on the render side, but someone will have to get to it.
Thanks for the clarification, we’ll simple comment-out empty taxonomy terms within config.toml for now, hopefully this issue is resolved in a future release.