Repository navigation
feat(sitemap): add SEO image to per-collection sitemaps (<image:image>) - #1504
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 547daa4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds the entry's SEO image to EmDash's native per-collection sitemaps using the Google image-sitemap extension, so page images can be discovered and indexed for Google Images.
Today the sitemap (
/sitemap-{collection}.xml) emits<loc>+<lastmod>(+hreflang) but no images. Google's image SEO guidance recommends advertising a page's images (and a representative/"preferred" image) in the sitemap. This wires the existing_emdash_seo.seo_image— the same "preferred image" already used forog:image— into the sitemap:Why only the SEO image (for now): it is the only image core knows generically across all collections and that is already a resolvable URL. Other images live in collection-specific media fields and in Portable Text bodies, and resolving those to correct (storage-key-based) URLs needs either per-image lookups or a usage index. That broader "all used images per page" work — plus a media "Used in" view and safe deletes — is proposed in a dedicated discussion as the natural follow-up.
Related discussion: #1503
Implementation
seo/media-url.ts(new): extracts the existingog:imageURL-resolution logic into a sharedbuildSeoImageUrl()(no behaviour change; removes a private duplicate inseo/index.ts).api/handlers/seo.ts: the sitemap query alreadyLEFT JOINs_emdash_seofor the noindex flag — now also selectsseo_imageand returns it per entry.astro/routes/sitemap-[collection].xml.ts: declares thexmlns:imagenamespace and emits one<image:image>per entry that has an SEO image.Type of change
Checklist
pnpm typecheckpasses (emdashpackage — ran clean)pnpm lintpasses (left to CI)pnpm testpasses (targeted:tests/integration/seo/*,tests/unit/seo/*— 72/72)pnpm formathas been run (left to CI)AI-generated code disclosure
Screenshots / test output