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

Question: How to disable inferred "Home" page title #249

Closed
lhsazevedo opened this issue Feb 27, 2021 · 4 comments
Closed

Question: How to disable inferred "Home" page title #249

lhsazevedo opened this issue Feb 27, 2021 · 4 comments

Comments

@lhsazevedo
Copy link

Is it possible to disable the "Home" page title when using home: true? I trying to keep just the site title.

Related code:

const inferTitle = (frontmatter: any, content: string) => {
if (frontmatter.home) {
return 'Home'
}
if (frontmatter.title) {
return deeplyParseHeader(frontmatter.title)
}
const match = content.match(/^\s*#+\s+(.*)/m)
if (match) {
return deeplyParseHeader(match[1].trim())
}
return ''
}

@ElMassimo
Copy link
Contributor

ElMassimo commented Mar 18, 2021

Not in the browser tab, but in social previews adding this to the frontmatter in index.md should do the trick:

head:
  - - meta
    - name: twitter:title
      content: My Site
  - - meta
    - name: og:title
    - content: My Site

@lhsazevedo
Copy link
Author

lhsazevedo commented Mar 18, 2021

Hm cool little hack, thanks.

For the titles, something like titleTemplate of Vue Meta would be great.
If you guys approve, I can try to implement it (Maybe I'll need some help along the way 😅)

@edimitchel
Copy link

I suggest to have this behavior : if title is set, use it, else if, use default home title.

const inferTitle = (frontmatter: any, content: string) => {        
    if (frontmatter.title) { 
        return deeplyParseHeader(frontmatter.title) 
    } 

    if (frontmatter.home) { 
       return 'Home' 
    }

    const match = content.match(/^\s*#+\s+(.*)/m) 
    if (match) { 
        return deeplyParseHeader(match[1].trim())         
    } 
    return '' 
}

@lhsazevedo
Copy link
Author

Related #263

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants