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.

Feature request: Support for defaultTitle

See original GitHub issue

Summary

Allow users to define a defaultTitle in gridsome.config.js to fall back to if a metaInfo.title is not provided in a page component.

We can look to React Helmet for reference.

Basic example

// gridsome.config.js
module.exports = {
  titleTemplate: '%s \u2013 Gridsome',
  defaultTitle: 'Gridsome'
}
<!-- pages/Index.vue -->
<script>
export default {
  metaInfo: {
    title: null,
  },
}
</script>
<!-- rendered HTML -->
<head>
  <title>Gridsome</title>
</head>

Motivation

This, I believe, would give users more granular control of their SEO, which is nice.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
miljan-aleksiccommented, Jan 26, 2020

Thumbs up for titleTemplate accepting a function as suggested by @thasmo, it should also provide the config as context: titleTemplate: ({title, config}) => {}.

I would open a PR if the feature is accepted, but I am a little bit sceptical judging the amount of unnatended ones so far 😦

2reactions
thasmocommented, Apr 14, 2019

Chiming in on this topic 'cause I’ve trouble configuring a proper per-page-title in combination with a configured site wide title and maybe my issue/requirements can benefit how the solution for this issue looks like.

In my case I want to define a site title and a per-page-title. I thought I could do it like this:

gridsome.config.js

module.exports = {
    siteName: 'SITE',
    titleTemplate: (title) => title ? `${title} - %s` : '%s',
};

Index.vue

<script>
export default {};
</script>

About.vue

<script>
export default {
    metaInfo: {
        title: 'ABOUT',
    },
};
</script>

I expected the final page’s title to be SITE for the Index.vue page and ABOUT - SITE for the About.vue page but it turns out, that it works differently and I’m not sure how I can handle this.

Optimally I can define a global titleTemplate for the whole application and configure a title per page, which gets used within the titleTemplate. It seems title completely overwrites the titleTemplate or something.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Request Template: How to Manage Suggestions at ...
Streamline and organize user feedback with this free feature request template. Available in Google Docs and Sheets (no email required).
Read more >
Feature Request: Support Help Section - Zendesk help
I see that when I "Get Help" from within Zendesk Support, a help bar displays where I can search HC topics before submitting...
Read more >
JazzHR: Award-Winning Recruiting Software for SMBs
Find and hire the right talent, fast with the only hiring platform built for businesses like yours. Request A Demo Try it Free....
Read more >
Booz Allen
As a consulting firm with expertise in analytics, digital, engineering, and cyber, we help businesses, government, and military organizations transform.
Read more >
Lever: Recruiting Software for More Hiring in Less Time
We designed features like this in LeverTRM with recruiters in mind so they can build relationships and help managers hire better candidates faster....
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