Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): add site title to meta title #2255

Merged
merged 4 commits into from
Jan 31, 2020

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Jan 30, 2020

Motivation

Resolves https://docusaurus.canny.io/admin/board/feature-requests/p/allow-browser-tab-title-to-have-a-prefix

Bcause this is the expected behavior (especially since it was in v1) - the site name is usually contained in the title itself and this is suitable for most websites (+ better for SEO).

The only thing I'm not sure about existing a tagline in the case when the title is not set, in v1 there was even a separate config parameter (disableTitleTagline) that removes the tagline from the final meta title, but I do not think it is a good idea to implement it in v2.

const title = this.props.title
? `${this.props.title} · ${this.props.config.title}`
: (!this.props.config.disableTitleTagline &&
`${this.props.config.title} · ${tagline}`) ||
this.props.config.title;

Maybe then do not include the tagline in the meta title, after all, this is typical only for the home page, for other pages without a title it is better to just use site title (IMO).

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Make sure site title is included in meta title (docs/blog/pages).

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@lex111 lex111 requested a review from yangshun January 30, 2020 11:36
@lex111 lex111 requested a review from wgao19 as a code owner January 30, 2020 11:36
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jan 30, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jan 30, 2020

Deploy preview for docusaurus-2 ready!

Built with commit fa1710f

https://deploy-preview-2255--docusaurus-2.netlify.com

@lex111 lex111 added the pr: new feature This PR adds a new API or behavior. label Jan 30, 2020
Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

LGTM. Can we change to either - or |? Self-merge

{title && <title>{title}</title>}
{title && (
<title>
{title} · {siteTitle}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think using - or | will be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yangshun done, but what about avoiding to use tagline if there is no title? I mentioned this in the PR description.

${siteTitle} · ${tagline} -> ${siteTitle}

Instead, use tagline only on the home page.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Don't use tagline elsewhere. I think if the tagline is too long it even looks weird to have it as the <title> on the homepage, just like ours :S

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excluded tagline from meta title of any page, but bring back it to title on home page.

@yangshun yangshun merged commit d1219b1 into facebook:master Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants