Improve page metadata for title and description (used in search results and social previews) - #69
Merged
Conversation
…ts and social previews) Previously, these looked very generic for most pages (essentially showing the same text for almost all pages, and just repeating the title twice for release notes). Now they look much more precise. :-) - If no title is available from the page config, fall back to the title in the section config (global collection) (analogously to how <title> tag is already computed) - Descriptions can be be specified in the section config or in the frontmatter of pages - If no description is specified, generate one instead from the first meaningful paragraph of the page - Fix section generator to properly parse frontmatter from _head.md instead outputting it verbatim Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the precision of page <title>, meta name="description", and Open Graph metadata so search results and social previews better reflect each page/section, including more helpful fallbacks when explicit metadata isn’t provided.
Changes:
- Add and propagate section/page descriptions via
_config.yml, page frontmatter, and_head.mdfrontmatter. - Update the section generator to parse
_head.mdfrontmatter instead of rendering it as content, and to provide a section-title fallback for metadata. - Introduce a post-render hook that derives a description from the first meaningful paragraph when none is provided, and patches rendered meta tags accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
index.html |
Reuses the welcome text as the page description via YAML anchor/alias to improve homepage metadata. |
_plugins/section_generator.rb |
Parses _head.md frontmatter, sets section-level description/title fallback flags for downstream metadata generation. |
_plugins/page_metadata.rb |
Adds description extraction and post-render meta tag rewriting for more accurate description and Open Graph tags. |
_pages/terse_guide.md |
Adds an explicit description in frontmatter for better previews. |
_pages/board.md |
Adds an explicit description in frontmatter for better previews. |
_downloads/_head.md |
Adds frontmatter description for the downloads section (now correctly parsed by the generator). |
_config.yml |
Adds a description for the documentation collection to provide a section-level fallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+46
to
+52
| def first_front_page_item_description(section) | ||
| item = section&.docs | ||
| &.select { |doc| doc.data['front-page'] } | ||
| &.min_by { |doc| doc.data['order'].to_i } | ||
|
|
||
| plain_text(item.content) if item | ||
| end |
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.
Previously, these looked very generic for most pages (essentially showing the same text for almost all pages, and just repeating the title twice for release notes). Now they look much more precise. :-)
(https://socialsharepreview.com/)