Skip to content

Fix Open Graph URL for generated guides pages - #516

Merged
jamesfredley merged 1 commit into
masterfrom
fix-guides-og-url
Jun 1, 2026
Merged

Fix Open Graph URL for generated guides pages#516
jamesfredley merged 1 commit into
masterfrom
fix-guides-og-url

Conversation

@jamesfredley

Copy link
Copy Markdown
Contributor

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.renderPages computed ogurl = siteMeta['url'] + page.path and merged it last, overriding any page-provided value. Those generated Page objects carry only a bare leaf filename as their path (e.g. 8.html), so the tag rendered as:

<meta property='og:url' content='https://grails.apache.org8.html'/>

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.renderPages now applies the computed default ogurl only when the page metadata does not already provide one, so a page can set its own.
  • GuidesTask sets the correct absolute ogurl in the front-matter of each generated page.

Before / after

Page Before After
/guides/index.html https://grails.apache.orgindex.html https://grails.apache.org/guides/index.html
/guides/versions/8.html https://grails.apache.org8.html https://grails.apache.org/guides/versions/8.html
/guides/tags/htmx.html https://grails.apache.orghtmx.html https://grails.apache.org/guides/tags/htmx.html
/guides/categories/gorm.html https://grails.apache.orggorm.html https://grails.apache.org/guides/categories/gorm.html

Testing

  • ./gradlew genGuides - all four generated og:url values 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 shared renderPages change is behavior-preserving for disk-parsed pages (none of which set ogurl).

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.

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
Copilot AI review requested due to automatic review settings June 1, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.renderPages to only compute a default ogurl when the page does not already provide one.
  • Add explicit ogurl front-matter entries to the guides index, tag, category, and version pages generated by GuidesTask.

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.

@jamesfredley
jamesfredley merged commit c6ec22d into master Jun 1, 2026
2 checks passed
@jamesfredley
jamesfredley deleted the fix-guides-og-url branch June 1, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants