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

Set title for posts written as React components #3143

Closed
melissamcewen opened this issue Dec 6, 2017 · 3 comments · May be fixed by danielres/gatsby#1
Closed

Set title for posts written as React components #3143

melissamcewen opened this issue Dec 6, 2017 · 3 comments · May be fixed by danielres/gatsby#1

Comments

@melissamcewen
Copy link
Contributor

Is there an easy way to do this? I'm using React Helmet for the head and it's easy to set a global title, but I'm wondering if there is a way to set the title of pages created as React components?

@mpartipilo
Copy link
Contributor

mpartipilo commented Dec 6, 2017

You can set the title from anywhere. React Helmet will use the last set value for the title (or any tag) from wherever it gets called.

@melissamcewen
Copy link
Contributor Author

melissamcewen commented Dec 6, 2017

oooo that's easy, thanks!

It seems to be working great. I just stuck a Helmet in the component. Sweet.

import React from 'react'
import Helmet from 'react-helmet'

const SecondPage = () => (
  <div>
    <Helmet
      title="TEST 123"
      meta={[
        { name: 'description', content: 'this is a test' },
        { name: 'keywords', content: 'test' },
      ]}
    />
    <h1>Test</h1>
    <p>Blah blah blah. </p>

  </div>
)

export default SecondPage

@benjaminhoffman
Copy link
Contributor

Hope that was helpful @melissamcewen ! Closing this issue for now as it appears your question has been answered. Feel free to re open if not :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants