react-helmet icon indicating copy to clipboard operation
react-helmet copied to clipboard

How do I append a value to the title?

Open kjoedion opened this issue 3 years ago • 3 comments

Is there a way to append an additional value to all page titles?

For example, something like:

${helmet.title.append(` - ${process.env.APP_NAME}`).toString()}

kjoedion avatar Nov 14 '22 13:11 kjoedion

you can use titleTemplate

<Helmet defaultTitle={process.env.APP_NAME} titleTemplate={%s - ${process.env.APP_NAME} } />

output

some Title - MyAwesomeWebsite.com https://www.npmjs.com/package/react-helmet

ajayunnikuttan avatar Nov 15 '22 05:11 ajayunnikuttan

Yeah but I'd have to put that in every component right?

Was wondering if there was a global way to apply it to all my components.

kjoedion avatar Nov 15 '22 05:11 kjoedion

you don't need to put in every component. you can add it on the root index.js file or routes.js file

ajayunnikuttan avatar Nov 15 '22 05:11 ajayunnikuttan