Add canonical link tags for item pages and bitstream downloads#5172
Draft
bram-atmire wants to merge 1 commit intoDSpace:mainfrom
Draft
Add canonical link tags for item pages and bitstream downloads#5172bram-atmire wants to merge 1 commit intoDSpace:mainfrom
bram-atmire wants to merge 1 commit intoDSpace:mainfrom
Conversation
Adds <link rel="canonical"> to item page HTML heads and a Link HTTP
header with rel="canonical" to bitstream download responses. This helps
search engines identify the preferred URL for each page, preventing
self-competition between /items/{uuid}, /entities/{type}/{uuid}, and
/items/{uuid}/full routes.
Both features are configurable via seo.canonical.items and
seo.canonical.bitstreams settings (enabled by default).
Refs DSpace#4509
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
References
Description
Adds
<link rel="canonical">to item page HTML heads and aLinkHTTP header withrel="canonical"to bitstream download responses, improving SEO by declaring preferred URLs.Instructions for Reviewers
List of changes in this PR:
SeoConfiginterface (src/config/seo-config.interface.ts) withcanonical.itemsandcanonical.bitstreamsboolean settings (both default totrue)HeadTagService: injectsLinkHeadService, adds<link rel="canonical">pointing to the simple item view URL (viagetItemPageRoute()), and removes it on every route change. This covers both simple (/items/{uuid}) and full (/items/{uuid}/full) views — the canonical always points to the simple view. Entity pages (/entities/{type}/{uuid}) get their own canonical. Handle URLs (/handle/{p}/{s}) already 301-redirect, so no canonical is needed there.BitstreamDownloadPageComponent: adds<link rel="canonical">to the HTML<head>(works for both SSR and client-side rendering) and appendsrel="canonical"to theLinkHTTP header (SSR only). ImplementsOnDestroyto clean up the tag.HeadTagServiceandBitstreamDownloadPageComponentcovering: tag added for Items, not added for non-Item DSOs, not added for non-DSO pages, removed on route change, respects configfalse, and cleanup on destroy.How to test:
npm run build:ssr && npm run serve:ssr<link rel="canonical" href="https://your-host/items/{uuid}">is present in the<head>/items/{uuid}/full), view source — canonical should still point to/items/{uuid}(without/full)/entities/{type}/{uuid}) — canonical should point to/entities/{type}/{uuid}curl -I https://localhost:4000/bitstreams/{uuid}/download— confirm theLinkheader containsrel="canonical"seo.canonical.items: falseorseo.canonical.bitstreams: falsein your config and verify the canonical tags are no longer addedNew configuration (in
config.ymlor environment config):Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.