Metadata for Discord previews

I’ve been trying to implement this feature on my website, googling around it seems I need to use

The ogp properties are meant to go in <head>, and I’m using a theme, so I put them in themes/theme-name/partials/head.html

But it doesn’t seem to take effect. Am I putting it in the right file?

It seems like it. However please note that this is just a guess.
If you want an informed answer you would need to share your project in the forum for people to see its structure.

Thank you for responding.

EDIT it seems like I fixed it, I removed the line with the template and manually type the og metadata in head.html.

I’ve noticed in layouts/partials/head.html l31:

{{ template "_internal/opengraph.html" . }}

However I don’t know where that file is, and I don’t have a folder named _internal.

Could this be causing a conflict with lines 46 and 47, which I manually added later? (l31 came by default with this theme which I forked)

It is a reference to the internal Open Graph template that ships with Hugo.


I was just looking at this, and from what I can gather, it’s just params in the config.toml correct?

For example, if I have the twitter banner in static/img/twitter-preview.png I’d have this in my config:

    twitter_cards = true
    images = ["img/twitter-preview.png"]

It seems pretty simple, but in practical terms it’s just not being displayed.

Is there any way to test this without actually deploying and checking twitter/discord? That makes the process a lot more cumbersome.

You can view the source of the page in the local server.

Anyway it’s very hypothetical without sharing the project or at least a sample that reproduces the behavior you encounter.

I understand, but I can’t share the whole project publicly since it contains sensitive data.

I could share the theme, but I don’t know if that would be enough. I wouldn’t know how to reproduce this with a sample, since the issue is in the interaction with twitter/discord, and that would imply building and deploying another site. Is this what you’d suggest doing?

I’m checking the metadata by inspecting the page and everything seems in order.

If everything is in order in the page source then I do not know why the preview does not show up on Discord or Twitter. Perhaps this is a more generic issue.

It shows up correctly not only in the local test deployment, but on the online website. Maybe it’s related to cacheing, even tho I’ve been hard refreshing discord, maybe i need to wait like a few days. Thank you for the assistance so far.

EDIT indeed it shows up now, just had to wait a bit

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.