Hi there ,
I’m not sure if this is the right place to ask how-to questions, if not, let me know and I’ll move it somewhere else.
I’d like to change the title of my pages and I was wondering if using something like Helmet is the right approach for that. Also, I noticed that the main index.html
has a default title set to:
<title><%= htmlWebpackPlugin.options.title %></title>
Where is that title come from?
Thanks in advance for your help.
Tobbe
September 22, 2020, 7:53am
2
Hi @pepibumur ! Welcome to the Redwood community forums
I think you’re right on track with the React Helmet idea! See this topic for some previous discussions on the subject
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.
pepibumur:
Also, I noticed that the main index.html
has a default title set to:
<title><%= htmlWebpackPlugin.options.title %></title>
Where is that title come from?
^^ This is just us being able to set the site title to project directly title at time of installation. It’s meant to be removed as needed.
React Helmet is great and highly recommended!
Have a look in packages/core/config/webpack.common.js
:
'styled-components': path.resolve(
redwoodPaths.base,
'node_modules',
'styled-components'
),
react: path.resolve(redwoodPaths.base, 'node_modules', 'react'),
},
},
plugins: [
!isEnvProduction && new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
title: path.basename(redwoodPaths.base),
template: path.resolve(redwoodPaths.base, 'web/src/index.html'),
inject: true,
chunks: 'all',
}),
new CopyPlugin([{ from: 'public/', to: '', ignore: ['README.md'] }]),
isEnvProduction &&
new RetryChunkLoadPlugin({
cacheBust: `function() {
return Date.now();
If I want to change it, I define my own web/config/webpack.config.js
in my app: