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

og:image doesn't work for featured_images in an asset pipeline #214

Open
andykorth opened this issue Sep 13, 2024 · 2 comments
Open

og:image doesn't work for featured_images in an asset pipeline #214

andykorth opened this issue Sep 13, 2024 · 2 comments

Comments

@andykorth
Copy link

If I place an image in /assets/images/, it displays correctly as a featured_image of my post, but when it's time to generate a opengraph meta data, it uses a url for that image that doesn't exist.

The line in question seems to be:
https://github.com/nusserstudios/tailbliss/blob/main/layouts/partials/meta.html#L14

Which either doesn't notify the asset pipeline that a new image needs to be generated, or that the source image needs to be included in the build. Not sure how that's supposed to work.

@andykorth
Copy link
Author

andykorth commented Sep 13, 2024

I don't entirely know what I'm doing, but I seem to have fixed it like this:

{{ with .Params.featured_image }}
	{{ with resources.Get . }}
		{{ $ogFeaturedImage := .RelPermalink }}
		<meta property="og:image" content="{{ $ogFeaturedImage | relURL }}" />
		<meta property="og:image:secure_url" content="{{ $ogFeaturedImage | absURL }}" />
	{{ end }}
{{ else }}
	<meta property="og:image" content="{{ .Site.Params.og_image | relURL }}" />
	<meta property="og:image:secure_url" content="{{ .Site.Params.og_image | absURL }}" />
{{ end }}

@nusserstudios
Copy link
Owner

That looks right to me. I'll take a look at it locally, and pull it in. Thank you @andykorth!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants