Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Boilerplate that connects Hugo static site generation with Webpack for SASS, ES6, minification, and cache-busted assets.

A full-stack Next.js TypeScript template focused on functionality over UI, featuring Zustand, TanStack Query, and ESLint 9 support.
hugo-webpack-boilerplate is a Boilerplate that connects Hugo's static site generation to Webpack's asset pipeline, letting developers use SASS, ES6, and hashed assets in Hugo projects.
hugo-webpack-boilerplate is an npm module that exports a preconfigured Webpack setup designed for sites built with Hugo. It takes Hugo's generated HTML and static files as input, processes them through Webpack loaders, and outputs optimized files to a dist/ folder. The project was created by Mark van Seventer and is released under the MIT License.
The core idea is that Hugo is great for static HTML but weak when you need SASS compilation, ES6 transpilation, minification, tree-shaking, or asset revving. This boilerplate hands those jobs to Webpack, giving you a conventional Hugo authoring workflow plus modern front-end optimization.
module.exports = require('hugo-webpack-boilerplate') to your webpack.config.js; no additional loaders or plugins needed.fromConfig to set hugoPublishDir (defaults to public/) and outDir (defaults to dist/).~scss/style.scss and Webpack compiles and minifies them.~js/script.js are bundled, transpiled, and tree-shaken during the build.style.hash.css), enabling cache busting for static assets.html-loader interpolation syntax ${require(...)} lets you embed images and other assets directly into Hugo templates.webpack -p for a production build with minimize, or webpack -w to start the local development server with watching.dist/ folder.webpack -w during development to get automatic rebuilds as Hugo regenerates pages.After installing via npm install hugo-webpack-boilerplate, you require the module from your webpack.config.js. The module reads Hugo's generated site from public/ (configurable), resolves asset references using a tilde convention and html-loader interpolation, runs Webpack's pipeline, and writes the optimized site to dist/ (configurable). Currently only hugoPublishDir and outDir are configurable via fromConfig; custom loaders and plugins are not yet supported.
UnCSS tries to load scripts from disk, and tilde-prefixed references don't resolve as file paths. The error is non-blocking, so the resulting stylesheet is still useful, but note that any selectors added dynamically by JavaScript will not be included in the CSS.
There is a known bug in watchpack that causes the watcher to reload the same files repeatedly until the files settle. It's an inconvenience, but it does not affect the final bundles.
No, not at this time. The fromConfig function only supports hugoPublishDir and outDir. The project's README invites users to submit an issue or pull request if they want this feature.
Yes, it is licensed under the MIT License, so you can use, modify, and distribute it freely, including in commercial projects.