I want to add OpenGraph metadata to my pages using the internal OpenGraph template. However, that expects images to be referenced in .Page.images in the front matter. However, for my theme I’m using .Page.bannerimage in the front matter to set a featured image. How can I use the OpenGraph template, without having to stick to .Page.images in every article?
Well, the error message says that you can merge maps (aka dict). But you’re probably (not enough context posted to really tell) using the current page (the “dot” you’re passing as the first parameter to merge).
Hi, thanks for your reply. Yes, the OpenGraph template apparently expects the current page as a parameter: https://gohugo.io/templates/internal/ So if I could merge additional values into the .Params dict, how to update that one in the Page variable?
Yeah, I understand where the error is coming from. However, my question is not about this error, but how to use the OpenGraph template with a different parameter for images. But apparently this is impossible?
This argument is getting you nowhere. page is an internal data structure, and why would or should the Hugo developers allow templates to manipulate that? The next person wants to remove a part of this structure, because they believe that they don’t need it…
If you do not like the behavior of the pre-defined template, write your own. You can use the pre-defined one as a starting point and modify its parameter list in every which way you like.
Okay, thanks. All you’re telling me is I’m doing it wrong, providing not enough context, using the merge method in the wrong way, using a “self-invented data structure”… I don’t think that trying to use existing code (the OpenGraph template) instead of reinventing the wheel is the wrong way. But apparently this isn’t possible, so yeah, probably I’ll have to maintain a copy of that template now.