Skip to content

feat: add pageTitleFormatter config - #2695

Merged
sy-records merged 4 commits into
docsifyjs:developfrom
sy-records:feat/pageTitleFormatter
Mar 23, 2026
Merged

feat: add pageTitleFormatter config#2695
sy-records merged 4 commits into
docsifyjs:developfrom
sy-records:feat/pageTitleFormatter

Conversation

@sy-records

Copy link
Copy Markdown
Member

Summary

If a pageTitleFormatter is provided, let the user format the name
(no automatic HTML stripping). Otherwise, default to stripping
HTML tags from the configured name.

Related issue, if any:

Close#2610

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

  • Yes
  • No

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

@vercel

vercelBot commented Mar 16, 2026

Copy link
Copy Markdown

@sy-records is attempting to deploy a commit to the Docsify Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercelBot commented Mar 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
docsify-previewReadyReadyPreview, CommentMar 16, 2026 10:20am

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Docsify configuration option to customize how the configured site name contributes to the browser tab title (document.title) during render, allowing users to override the default “strip HTML tags from name” behavior.

Changes:

  • Introduces pageTitleFormatter config option (default null).
  • Updates render event logic to use pageTitleFormatter(name) when provided, otherwise keep existing HTML-stripping behavior.
  • Documents the new option in the configuration reference.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

FileDescription
src/core/event/index.jsUses optional pageTitleFormatter when composing document.title during onRender().
src/core/config.jsAdds pageTitleFormatter to default config with JSDoc typing.
docs/configuration.mdDocuments pageTitleFormatter option and provides an example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment threadsrc/core/event/index.js
Comment threadsrc/core/config.js
Comment threaddocs/configuration.md
Comment threadsrc/core/event/index.js

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new configuration option to customize how the Docsify site name contributes to the browser document title during render, while preserving the existing default behavior when the option is not set.

Changes:

  • Introduces pageTitleFormatter config option (default null) to optionally format the site name for document.title.
  • Updates the render event handler to use pageTitleFormatter(name) when provided; otherwise keeps HTML-tag stripping fallback.
  • Documents the new configuration option in docs/configuration.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

FileDescription
src/core/event/index.jsUses optional pageTitleFormatter to compute the site-name portion of the page title on render.
src/core/config.jsAdds pageTitleFormatter to the default config object (typed, default null).
docs/configuration.mdDocuments pageTitleFormatter with usage example and default behavior notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment threadsrc/core/event/index.js
Comment threaddocs/configuration.md

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new configuration hook to customize how the Docsify site name is incorporated into the browser document title, primarily to support HTML-containing names without automatic stripping.

Changes:

  • Add pageTitleFormatter to the default config schema.
  • Update title composition in onRender() to optionally delegate site-name formatting to pageTitleFormatter.
  • Document the new configuration option in docs/configuration.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

FileDescription
src/core/event/index.jsUses optional pageTitleFormatter when composing document.title from name and current section.
src/core/config.jsAdds pageTitleFormatter to the default config shape/type annotations.
docs/configuration.mdDocuments pageTitleFormatter option and provides an example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment threadsrc/core/event/index.js
Comment threadsrc/core/event/index.js

@paulhibbittspaulhibbitts 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.

In terms of testing, I've created a codesandbox:
https://codesandbox.io/p/sandbox/loving-williamson-glynzz

Define name as:

name: " <b>Simple</b> <i>Docsify</i> Template ",

And tested the following:

pageTitleFormatter(name) {
// return name ? name.replace(/<[^>]+>/g, "").trim() : "";
return name ? name.trim() : ""; // matches nothing, effectively a no-op
},

First option striped all HTML from page title, second option served to verify non-striping behavior.

@sy-records
sy-records merged commit f3ab502 into docsifyjs:developMar 23, 2026
12 checks passed
@sy-records
sy-records deleted the feat/pageTitleFormatter branch March 23, 2026 02:54
@sy-recordssy-records mentioned this pull request Jul 3, 2026
Sign up for freeto 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.

Alternative Page Title Generator [v5-rc]

3 participants

@sy-records@paulhibbitts