I'm working on a static site project, and have to now add multiple pages using the same header and footer. I'm trying to do this by turning the header.html and footer.html files into partials.
I've setup my webpack.config.js to use HtmlWebpackPlugin where the template is the index.html file.
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
]
I've also called the partials in the index.html file as follows:
<body>
<%= require('html-loader!./partials/header.html').default %>
<%= require('html-loader!./partials/home.html').default %>
<%= require('html-loader!./partials/footer.html').default %>
</body>
This works on the index file. But now I've got to add a portfolio.html page and reuse the header and footer.
When I call the partials the same way, they render as strings on the html page
Could someone help me with this? I don't know how to reuse the partials in other html pages.

The issue has nothing to do with
html-loader. You didn't usehtml-webpack-pluginto process theportfolio.htmlfile. This plugin will use ejs/lodash template by default to process the special template tag<%= >.See Generating Multiple HTML Files:
E.g.
Project structure(after building):
src/index.html:src/portfolio.html:src/partials/header.html:src/partials/footer.html:src/partials/home.html:webpack.config.js:Build logs:
Output
dist/index.html:dist/portfolio.html:package.json: