Error with internal opengraph.html

I get the error

_internal/opengraph.html:26:18: executing “_internal/opengraph.html” at <.>: range can’t iterate over Hugo Releases

if I use {{ template “_internal/opengraph.html” . }} in my baseof.html. Strange, didn’t happen before. Any ideas?

Hello Leo,

are you so kind to share your website with us, e.g. as repository on GitHub? Having the actual source makes it easier to isolate the issue.

Sure, here it is: Hugo Template with OpenGraph

This is a working template to test Hugo functions and prepare a basic template for all projects. The branch is “hugo-check-og”. The Readme and a lot of other stuff is in German but you’ll get the hang of it.

The opengraph template is in layouts/partials/site/head.html which is called by layouts/_default/baseof.html. If I take out the opengraph internal template and put in my own from layouts/partials/meta/og.html it works fine.

You can start Hugo with npm run prodnomin to get the production environment and uncompressed html in build/public.

The rest should be self explaining.

Thank you very much for taking the time to check.

Best regards from Germany, Leo

Is it just me or do you get stuck when you click on the link? Discourse doesn’t finishes the redirect.

No, me as well.

Here’s the link again:

Perhaps you copy it to your browser if it still doesn’t work. The repo exists and I can see it through the above link

Hello Leo,

excuse the slow response times. I’ve been busy the last couple of days.

Nonetheless, the link above works now but the repo isn’t public. Hence I can’t have a look at your website.

Shame on me, it’s public now…

I found a way to circumvent the error messages. In the front matter of content/tags/ replace series : Hugo Releases with series : ["Hugo Relase"] and create a new taxonomy in the config named series.

This is simply amazing! Who are you? Hugo God? Thank you very much. I saw that as well and always had the feeling that the front matter in was kind of wrong for series. But I did not see the context.

I owe you something!

Best regards from Germany, Leo

I simply looked into the internal template of the short code at the given line from the error message. The short code tried to iterate over the .Pages attribute of the “series” taxonomy.

Since it wasn’t defined anywhere I added it quickly to the config. The “series” taxonomy was only used in a single file. As a post can theoretically be part of multiple series, over which will be ranged in the short code, it seemed naturally to put “Hugo releases” into an array.

Overall, it’s more reverse-engineering than magic :wink:

Cool, tnx for explaining the process. That will help me a lot. For me, working around 3 weeks with Hugo, it’s already a complex template because I wanted to try out as much as possible for learning purposes.