Repository navigation
feat: Add last updated date and structured data to docs pages - #21070
Conversation
Derive each page's last updated date from the last commit that changed its source file, computed once when the doc tree is generated. Show it under the page description, and expose the same date as schema.org dateModified, as sitemap lastmod, and in the Markdown export frontmatter. Vercel clones only 10 commits, so the build fetches the commit history (without file contents) first, and leaves dates out if it can't. Bulk edits listed in .last-updated-ignore-revs and .git-blame-ignore-revs don't count as updates. Refs DEVEX-942 Co-Authored-By: Shannon Anahata <shannon.anahata@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pages with an MDX override in md-overrides/ rebuilt their export frontmatter without the doc tree's last updated date.
Vercel's build checkout has no origin remote, so the history fetch failed and the build skipped last updated dates. Add origin from VERCEL_GIT_REPO_OWNER and VERCEL_GIT_REPO_SLUG when it's missing. Co-Authored-By: Shannon Anahata <shannon.anahata@sentry.io>
Add a BreadcrumbList that matches the visible breadcrumbs on docs pages, and WebSite and Organization data on the home page. The Organization uses the same @id as sentry.io so search engines treat them as one entity. Move the JSON-LD script tag into a shared component. Co-Authored-By: Shannon Anahata <shannon.anahata@sentry.io>
| * structured date to match. | ||
| */ | ||
| export function LastUpdated({date, title, description}: Props) { | ||
| const structuredData = { |
There was a problem hiding this comment.
I'm just brushing up on JsonLd types, but I think adding the canonical url and even publisher here would be a nice boone to SEO/AEO so the robots associate the structured data with a specific resource.
The url would serve a different semantic purpose than what's happening with the breadcrumb list. But I think you could get the canonical url from resolvePageCanonical() in the same imported utils that are used in the breadcrumb util.
There was a problem hiding this comment.
Good call, added both in 1fd733d3c. url is the page's canonical URL from resolvePageCanonical(), the same value as the <link rel="canonical"> tag, so it also follows customCanonicalTag. publisher is Sentry as an Organization with the same @id (https://sentry.io/#organization) as the home page and sentry.io, so they all point at one entity. That object now lives in jsonLd.tsx, so the home page and the article data share it.
via shannon.anahata.
jaffrepaul
left a comment
There was a problem hiding this comment.
I added a comment about JsonLd types that could beef this up 👍
Ties the TechArticle to its canonical page URL and to Sentry as the publisher, using the same Organization @id as the home page and sentry.io.
DESCRIBE YOUR PR
Refs DEVEX-942
Adds a "Last updated" date to every docs page that has a source file, so readers, search engines, and LLMs can tell how fresh a page is. Also adds schema.org breadcrumb data to docs pages, and website and organization data to the home page.
Where the date comes from
scripts/last-modified.tsruns onegit log --first-parent --no-renames --name-onlyoverdocs/anddevelop-docs/whengenerate-doctreeruns, and stores the newest commit date for each page'ssourcePathaslastModifiedon the doc tree node. Pages that inherit sharedcommon/content get the date of that shared file.git fetch --unshallow --filter=blob:none origin <HEAD>, which fetches the commit history without file contents. Vercel's checkout has nooriginremote, so the script adds one fromVERCEL_GIT_REPO_OWNERandVERCEL_GIT_REPO_SLUGwhen it's missing. If history is still unavailable, it logs a warning and leaves dates out instead of showing wrong ones. The build never fails because of this..git-blame-ignore-revs(formatting) and the new.last-updated-ignore-revs(bulk edits that don't change what a page says) don't count as updates. Without that, hundreds of pages would show the dates of docs: De-duplicate platform SDK meta descriptions #19123 (meta description de-dupe) and docs: Add trailing slashes to internal links to avoid redirects #19639 (trailing slashes). A file that only ignored commits touched still gets their date..md/.mdxchanges count, so image-only commits don't move the date.Where the date shows up
Last updated: <time datetime="…">Month D, YYYY</time>. Versioned pages (__v…) don't show it, since they have their own source files.dateModifiedin aTechArticleJSON-LD block (headline,description,dateModified, the canonicalurl, and Sentry aspublisher), next to the visible date. Google asks for the two to match, so both use UTC.<lastmod>insitemap.xml.last_updatedin the Markdown export frontmatter. This changes every export once, so the first build after merge re-uploads them all to R2.Other structured data
BreadcrumbListbuilt from the same items as its visible breadcrumbs, with canonical URLs. Google can show this path in search results instead of the raw URL.WebSite(name "Sentry Docs") and anOrganizationfor Sentry, with its logo and social profiles. TheOrganizationuses the same@idas the one on sentry.io (https://sentry.io/#organization), so search engines treat both as one entity. The logo is a newpublic/sentry-logo.png(512×512, fromsrc/logos/sentry-logo-dark.svg), because the logo URL in sentry.io's own markup redirects to a login page.JsonLdcomponent renders all JSON-LD blocks, andSENTRY_ORGANIZATIONkeeps the home pageOrganizationand theTechArticlepublisher the same.Known limits
includes/andplatform-includes/don't move a page's date yet. Rolling include dates up into the pages that use them can come later.pnpm devbuilds the doc tree without git dates, so the line doesn't render locally. Use the Vercel preview.Open decisions
.last-updated-ignore-revsfor now, because it only changed SEO descriptions.IS YOUR CHANGE URGENT?
PRE-MERGE CHECKLIST
via shannon.anahata.
--
View Session [Sentry]