question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default title prop

See original GitHub issue

It would be nice to set a default title. Let’s say the website is Github.

I’d do (in _app.js):

<NextSeo titleTemplate="%s - Github" defaultTitle="Github" />

If there’s no title set later in the document, it would fall back to Github. If there is, it would be replaced with the title template, e.g. Blog - Github.

There’s a few nice UX wins with this, happy to expand more if they’re non-obvious.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
trevorbladescommented, Nov 27, 2020

@switz @garmeeh I just opened a PR that adds a defaultTitle param in the style of react-helmet. In short, if a defaultTitle is added, then pages with no title defined will still get the default value.

For example, let’s say I had the following in my _app.js:

<DefaultSeo titleTemplate="%s - MyApp" defaultTitle="MyApp" />

My home page might look like this:

<NextSeo title="Sweet keywords" />
// renders <title>Sweet keywords - MyApp</title>

But another page in my website that doesn’t have a title set would still render a <title> tag with “MyApp” only.

3reactions
switzcommented, Jun 3, 2020

Well, I think fallbackTitle would make more sense for my use-case. But there may be other usecases that prefer the other. I’ll always have a titleTemplate set (in app.js), but for example, if I set title to Github on the index page, it would return Github - Github (due to the title template). So if I was able to set fallbackTitle when there is no title set, it would negate the titleTemplate.

I believe this also has the benefit of having a preliminary title set in the case of html streaming, before the full page has rendered out, but I could be wrong, I’m not an expert in that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

title - HTML: HyperText Markup Language - MDN Web Docs
The title global attribute contains text representing advisory information related to the element it belongs to.
Read more >
How to change the style of the title attribute inside an anchor ...
How do I change the presentation of the "title" attribute in the browser?. By default, it just has yellow background and small font....
Read more >
HTML Global title Attribute - W3Schools
The title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves...
Read more >
How to Change the Style of the "title" Attribute Within ... - W3docs
Set the border-bottom and text-decoration properties for the class attribute of the <a> tag. Add the :hover pseudo-class to the class attribute of...
Read more >
ServiceLink Default Title & Close | svclnk.com
Title property report and title grading. Understanding a property's lien position and resolving any title issues is critical during the loan modification ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found