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

OpenGraph Images #114

Open
davidvkimball opened this issue Jun 26, 2024 · 6 comments
Open

OpenGraph Images #114

davidvkimball opened this issue Jun 26, 2024 · 6 comments

Comments

@davidvkimball
Copy link
Contributor

Is there a straightforward way to add a global OpenGraph image that will work for any site page or post, but then update that OpenGraph image on a per-page permalink basis if another image is specified? I'm thinking, for example, using image as defined by the post's schema, or maybe another way for static/special pages.

I noticed OpenGraph titles, descriptions, URLs, and authors are specified in this template already, just not images.

@saicaca
Copy link
Owner

saicaca commented Jun 27, 2024

There's already a PR for OG #80, but I will need some additional time to refine the image design.

@davidvkimball
Copy link
Contributor Author

That is extremely helpful, thank you. I have gone ahead and implemented my own version for it - I am just having difficulty being able to specify a custom open graph image on a per-post and per-page basis. Is there a quick explanation for that? I tried adding ogImage to the post schema but it seems to ignore it, and I'm not sure what to do for pages in spec.

@saicaca
Copy link
Owner

saicaca commented Jun 29, 2024

You might need to add a parameter to both Layout and MainGridLayout to pass the image path to Layout.

I’m not sure what you mean by adding ogImage to the post schema. Do you mean that you added a parameter to the FrontMatter but are unable to read it?

@davidvkimball
Copy link
Contributor Author

Yes, that's exactly what I'm saying.

Example post:

title: Download Windows 11 Folder Icons
published: 2024-06-24
description: Folder icons for Windows 11 in .ico format.
image: ./cover.png
altText: Assortment of Windows 11 folder icons in File Explorer.
ogImage: ./cover.png
category: Tech
draft: false

Here I want it to read ogImage and use it as the og:image instead of the automatically generated one, and I also want it to skip the auto generation process for specifically that blog post if it detects an ogImage property set.

I have implemented nearly all of #80 with some slight tweaks.

Attached is my WIP blog structure if it helps:
static-blog.zip

Hopefully what I'm saying makes sense! I'm a little out of my element here, so my apologies if I'm overlooking something silly. 😅

@davidvkimball
Copy link
Contributor Author

If it's helpful, I also have the live version of my site available for viewing here: https://davidvkimball.com

@davidvkimball
Copy link
Contributor Author

I have since removed my ogImage frontmatter, I'm thinking something simpler like image = opengraph? boolean, default false. If true, use the image as the opengraph image for that post instead, creating a folder directory with the post's slug and placing a copy of the image with its original filename there. I will experiment to see if I can get it working.

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