Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugo doesn't like dashes in frontmatter variable names #345

Closed
jayeless opened this issue May 17, 2021 · 1 comment · Fixed by #347
Closed

Hugo doesn't like dashes in frontmatter variable names #345

jayeless opened this issue May 17, 2021 · 1 comment · Fixed by #347
Assignees
Labels
bug Something isn't working

Comments

@jayeless
Copy link

Or more specifically, your front matter itself can have hyphenated variable names, but you can't then reference those variables in your Hugo templates, which makes them useless. Apparently this is a limitation of the Go templating parser/lexer.

So how I came across this is that once I worked around #344, I found that anything with the variables like-of, bookmark-of, in-reply-to, repost-of and mp-syndicate-to would write successfully to my repository, but (after I edited my templates to use those variables) Hugo would then fail to build. The solution was quite easy: I just replaced the hyphens that would be printed to my interactions' front matter with underscores, which Hugo is fine with. So instead of these lines I have:

      ...(properties['bookmark-of'] && {'bookmark_of': properties['bookmark-of']}),
      ...(properties['like-of'] && {'like_of': properties['like-of']}),
      ...(properties['repost-of'] && {'repost_of': properties['repost-of']}),
      ...(properties['in-reply-to'] && {'in_reply_to': properties['in-reply-to']}),
      ...(properties['post-status'] === 'draft' && {draft: true}),
      ...(properties.visibility && {visibility: properties.visibility}),
      ...(properties.syndication && {syndication: properties.syndication}),
      ...(properties['mp-syndicate-to'] && {'mp_syndicate_to': properties['mp-syndicate-to']})
@paulrobertlloyd
Copy link
Collaborator

@jayeless Thanks for reporting. I have update the Hugo preset so that all frontmatter keys are now camelCased. I used this format as that appears to be the flavour favoured by Hugo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants