Skip to content

Fix the duplicated site name in page titles - #335

Merged
rich-iannone merged 8 commits into
posit-dev:mainfrom
has2k1:fix-duplicate-site-name-in-title
Sep 1, 2026
Merged

Fix the duplicated site name in page titles#335
rich-iannone merged 8 commits into
posit-dev:mainfrom
has2k1:fix-duplicate-site-name-in-title

Conversation

@has2k1

@has2k1 has2k1 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

This PR composes page titles during the Quarto render instead of rewriting them afterwards, so the site name is added once. Great Docs now bundles a metadata.html template partial and writes it into the build directory at build time.

Fixes #327

Page titles previously appended the site name after rendering, even when
the rendered title already contained it. This produced values such as
`Great Docs | Great Docs`.

Apply the configured template while Quarto renders each page. Pages
without their own title now show the site name once. `og:title` and
`twitter:title` inherit the corrected page title.
The SEO audit previously treated a pipe or hyphen as evidence that a
page title used the configured template. It missed the en dash that
Quarto uses and flagged eight valid titles on the Great Docs site,
including the main and versioned home pages.

Check for the configured site name instead. Exclude the main home page,
whose title is only the site name, and redirect stubs, which send readers
elsewhere. Update the affected audit test to assert the reported page
count.
Page-title generation replaces the <title> element in Quarto's metadata
partial. Reading the installed partial for every build required a subprocess
and allowed identical sources to produce different head markup with different
Quarto versions.

Bundle the partial with Great Docs. From 2022 through August 2026, Quarto
changed this file twice, and both changes affected only the title element
that the build replaces. A test compares every other line with the installed
Quarto partial and skips when the file is unavailable.
Page-title templates required both `{page_title}` and `{site_name}`, so
`{page_title}` alone fell back to Quarto's default and appended the site
name. The same template worked before page-title generation moved into the
Quarto render.

Require only `{page_title}`. Treat `{site_name}` as optional and omit the
site-name component from titled pages when it is absent.
`seo.enabled` controls all SEO features. Moving page-title generation into
the Quarto render bypassed this setting, so disabling SEO still rewrote page
titles.

Skip the title partial when `seo.enabled` is false and retain Quarto's
default page titles.
The SEO audit required each ordinary page title to contain the site name. A
template without `{site_name}` therefore counted every ordinary page as
missing the name, even when its title matched the configuration.

Apply the site-name requirement only when the page-title template contains
`{site_name}`.
A template such as `Docs: {page_title}` added `Docs:` to pages without
their own title. Quarto already uses the site name for these pages, so the
home page rendered as `Docs: <site name>` instead of the site name alone.

Apply the complete template only to titled pages. Preserve Quarto's title
for untitled pages.
An empty `seo.title_template:` value parses as `null`. The build and SEO
audit assumed a string, which caused the build to raise `TypeError`.

Treat every non-string value as unsupported. Emit one warning, preserve
Quarto's default page titles, and skip the audit's site-name check.
@has2k1

has2k1 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

In the discussion in #327, the conclusion had been to only add a site title if it did not appear in the page title. I backed off it for a smaller solution that does not introspect every title. We can revisit this when if we need that enhancement and we have some scoping for what happens in core.py.

@rich-iannone rich-iannone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!!

@rich-iannone
rich-iannone merged commit 128f66f into posit-dev:main Sep 1, 2026
8 checks passed
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.

Site name duplicated in <title> on every page ("Great Docs | Great Docs")

2 participants