-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Clarify how to implement social image URLs #8149
Comments
Why can't you use images in |
More precisely, I was not able to construct canonical URLs for images in Let's say here I have an MDX file where I want to declare path to an image to be used in the social card:
If the image is in In my current code I store these types of images in |
Ah yes, for images in Markdown content, you'd need to use Content Collections for images to be resolved. https://docs.astro.build/en/guides/images/#images-in-content-collections |
I haven't noticed Content Collections, will give them a try. |
Will accept a PR if anyone wants to add the extra context that @Princesseuh suggested! I could see a line added underneath the existing paragraph, something like:
(Would need a check to make sure that's exactly what was intended!) |
📚 Subject area/topic
Runtime API
📋 Page(s) affected (or suggested, for new content)
https://docs.astro.build/en/reference/api-reference/#astrocanonicalurl
📋 Description of content that is out-of-date or incorrect
I was implementing logic for social image URLs in astro and md layouts and couldn't fnd any example that would point me in the right direction re. building canonical URLs.
The page I mentioned recommends using
Astro.url
, but this will generate localhost URLs.Another thing is, reaching for images in
src/
won't work.So not sure where exactly in docs but would love to see this clarified in a single place:
public/
site
global propertyUse
URL.new(asset_path, Astro.site)
🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
No response
The text was updated successfully, but these errors were encountered: