Fix Open Graph URL for generated guides pages - #516
Merged
Conversation
renderPages computed ogurl as <site> + Page.path and merged it last, overriding any page-provided value. The generated guides pages (index, tags, categories, versions) carry only a bare leaf filename as their path, so og:url rendered as e.g. https://grails.apache.org8.html instead of https://grails.apache.org/guides/versions/8.html. Disk-parsed main-site pages were unaffected because their path is already root-relative. Let renderPages keep a page-provided ogurl (computing the default only when absent), and have GuidesTask set the correct absolute ogurl in the front-matter of each generated page (index, tags, categories, versions). Assisted-by: claude-code:claude-4.8-opus
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect Open Graph URLs (og:url) on generated guides pages by allowing per-page metadata to supply ogurl, and by explicitly setting the correct absolute ogurl when generating the guides index/tag/category/version pages.
Changes:
- Update
RenderSiteTask.renderPagesto only compute a defaultogurlwhen the page does not already provide one. - Add explicit
ogurlfront-matter entries to the guides index, tag, category, and version pages generated byGuidesTask.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| buildSrc/src/main/groovy/website/gradle/tasks/RenderSiteTask.groovy | Preserves page-provided ogurl and applies the computed default only when missing. |
| buildSrc/src/main/groovy/website/gradle/tasks/GuidesTask.groovy | Emits correct absolute ogurl in front-matter for all generated guides pages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Fixes a pre-existing bug in the Open Graph URL (
og:url) of the generated guides pages (the guides index and the per-tag, per-category, and - since #515 - per-version pages).RenderSiteTask.renderPagescomputedogurl = siteMeta['url'] + page.pathand merged it last, overriding any page-provided value. Those generatedPageobjects carry only a bare leaf filename as their path (e.g.8.html), so the tag rendered as:instead of the real URL. Disk-parsed main-site pages were unaffected because their path is already root-relative (e.g.
/faq.html).Fix
RenderSiteTask.renderPagesnow applies the computed defaultogurlonly when the page metadata does not already provide one, so a page can set its own.GuidesTasksets the correct absoluteogurlin the front-matter of each generated page.Before / after
/guides/index.htmlhttps://grails.apache.orgindex.htmlhttps://grails.apache.org/guides/index.html/guides/versions/8.htmlhttps://grails.apache.org8.htmlhttps://grails.apache.org/guides/versions/8.html/guides/tags/htmx.htmlhttps://grails.apache.orghtmx.htmlhttps://grails.apache.org/guides/tags/htmx.html/guides/categories/gorm.htmlhttps://grails.apache.orggorm.htmlhttps://grails.apache.org/guides/categories/gorm.htmlTesting
./gradlew genGuides- all four generatedog:urlvalues now resolve correctly (verified in the built HTML)../gradlew build- main-site pages are unchanged (https://grails.apache.org/community.html,/faq.html,/index.html), confirming the sharedrenderPageschange is behavior-preserving for disk-parsed pages (none of which setogurl).Notes
This was flagged during the review of #515 as a pre-existing issue that the new version pages inherited; fixing it here in a focused, separate PR.