-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(open-graph): Allow custom OG images from any paths or URLs #1592
base: v4
Are you sure you want to change the base?
Conversation
Just a thought, but can't you already do this by prepending Basically the URL isn't restricted to the |
I just learned about dot-segments in URIs for the first time 😄 Wouldn't it be a bit hacky and esoteric to non web developers though? I'd assume reusing an image from a post as OG image is a common pattern. IMHO |
Arguably, one should not be putting an image from the note as the og-image, as those should be limited in resolution. Basically I assume IF you use an image from your note as your page-specific og-image, that you generally would use a lower resolution version. Also, I'm pretty sure the og-image used on anything except the page itself. Unless you're rich-linking to the page you're currently on, which seems redundant. |
I didn't mean the original images exactly when I said "reusing", I only meant a version of it: definitely needs to be downsized and cropped first, but reusing an image from the article is quite common. Many substack articles do this for example, here's one. My 2 cents on why article-specific OG images (i.e. custom OG in frontmatter) may not typically be from the
@saberzero1 Please feel free to close this PR if you think there is a need to enforce OG image to be stored in |
My biggest caveat with your first point is that neither the current version nor your proposed change allows for arbitrary CDNs to work. |
I was more talking about that IF you have an external CDN to host your images, it won't work in the current and proposed change anyway. So your point about external CDNs is kinda moot either way. Arguably it should be supported, but that's not necessarily related to this PR. A simple solution could be to do some checks. Like if the URL starts with I'm not entirely sure if Quartz includes all image files in the content folder, even if they are not linked anywhere. If they aren't, we should tell Quartz to add any image linked in frontmatter to the build as well. The static folder always emits all files inside. |
Yes Quartz does emit all files in the content folder. That's how I serve
Thank you for explaining. I now understand that you interpreted "CDN" as "external image hosting service" initially, that's where the confusion began. Just to clarify, when I said "CDN" I meant "CDN service Quartz site owner owns and uses for their own domain", it does not include "CDN services used by any external endpoints included by the site owner". I do like your suggestion to expand this PR to support full URLs if user provides one, I think hosting social images elsewhere is also a valid use case. I pushed in a change that does a simple URL scheme regex check to see if the frontmatter link is a valid URL. |
a228274
to
73fc1ce
Compare
You know, I was thinking, several problems would be resolved by pushing the content of the There are some reasons to not do this, like potentially conflicting files. (Same file in At the same time, I suspect if I add a Anyhow, above is not related to your PR. I'll review later today. |
Proposing a small change to remove the
static
directory restriction when setting OG image path in frontmatter. Now it's either relative to the base URL, or a full URL.So if someone wants to reuse an image
assets/cover.png
from their blog post in thecontent
directory, they can setsocialImage
to sayassets/cover.png
. If the image is in thestatic
directory, then they need to explicitly include it in the path:static/cover.png
. If it's hosted elsewhere e.g.https://example.com/cover.png
, thensocialImage
value should be the full URL including the HTTP protocol.