Access webpack var in a page

I see that in the generated index.html the title var from webpack config file is used. How do I do the same in a page.js file? Specifically I want to use the title in a layout file.

This is set in webpack over here:

I would either change the title in index.html manually, but if you need it to be dynamic you could set this via a custom webpack config:
https://redwoodjs.com/guides/webpack-config

Maybe you create an app.json file that this webpack config reads.

And then you could use something like React Helmet:
GitHub - nfl/react-helmet: A document head manager for React to modify the title.

This seems a bit more difficult than it should be to me, and this should be something that we’re making easy for you to do.

Thanks. I want to use the same title everywhere, at least for now, but I don’t want to have separate instances of the text. Especially thinking about i18n.

1 Like