A Hugo boilerplate for building modern websites ?
This boilerplate wraps Hugo with Gulp as your local development build pipeline.
PostCSS and Webpack + Babel are used for CSS and JS compiling & transpiling.
BrowserSync is used for providing a modern local development experience, allowing you to preview your site on multiple devices in sync.
BrowsersList is used for configuring Browser support.
SVG Sprite is used to generate an SVG Sprite.
To use Gulp, you must have Node and NPM installed.
Once the prerequisites are installed, clone the repository to your local machine, and then run:
npm install
This will install Hugo as well as all of the Node dependencies needed to run your Hugo environment. This may take a little while!
All development tasks are performed using npm run. See "scripts"
in package.json for a full list of commands.
Local development is powered by BrowserSync, you will be able to develop sites rapidly through:
http://localhost:3000/
.Running the local development server is as simple as running:
npm start
This will display all draft, future-dated, or expired content, which is not included in your production build.
If you'd like to develop with the site as it will appear in production, run:
npm run preview
To generate a final production build on your local machine you can run:
npm run build
The fresh production build of your site will end up in the dist/
directory.
All of Hugo's CLI commands can be run through NPM by running:
npm run hugo -- <command> --<param>
For example:
npm run hugo -- new posts/example-post.md
// => creates a new post at hugo/content/posts/example-post.md
.
├── .tmp/ // Temporary directory for development server
├── dist/ // The production build
├── hugo/ // The Hugo project; content, data and static files
| ├── .forestry/ // Contains Forestry.io configuration files
| ├── content/ // Where all site content is stored
| ├── data/ // TOML, YAML or JSON files containing site data
| ├── layouts/ // Your site's layouts
| | ├── partials/ // Your site's partials
| | └── shortcodes/ // Your site's shortcodes
| ├── static/ // Where all static files live
| | ├── css/ // Where compiled CSS files live
| | ├── js/ // Where compiled JS files live
| | └── uploads/ // Where user uploads are stored
| └── config.toml // The Hugo configuration file
└─── src/
├── css // CSS/SCSS source files to be compiled to /css/
└── js // JS source files to be compiled to /js/
Any SVGs found in src/img/
will be combined into a single SVG Sprite at hugo/static/svg/sprite.symbol.svg
.
This boilerplate comes with a simple partial for using SVGs in your layouts. You can select an svg by passing in it's ID.
{{/* Using a logo stored at src/img/github.svg */}}
{{ partial "svg" (dict "id" "github" "class" "optional-class" "width" 32 "height" 32) -}}
Note: the class
, width
, and height
params are optional
This boilerplate comes with standard ESLint and StyleLint configurations that will lint your CSS and JS for errors or common style issues, which work with most popular IDEs.
The tests can also be run from the command line:
npm run eslint
npm run stylelint
If you want to automatically fix lint errors, you can do this from the command line as well:
npm run eslint:fix
npm run stylelint:fix
This boilerplate is self-cleaning, and will remove the production dist/
and development .tmp/
folders every time a command is run to ensure that their contents are always up to date.
If you wish to manually cleanup, run:
npm run clean
All build tasks are handled by Gulp and are located in gulpfile.babel.js
. All parts of the build are configurable in discrete files to make management easy.
All build source and destination paths can be configured from gulp.config.js
.
The build commands for Hugp can be configured from gulp.config.js
. Build commands are set based on the NODE_ENV
environment variable. You can optionally load different args using the GENERATOR_ARGS
environment variable.
Four options are available:
default
: the default build commands that are always rundevelopment
: additional build commands for the development serverpreview
: additional build commands for a production development serverproduction
: additional build commands for production buildsThe configuration for BrowserSync is found in .browsersyncrc.js
The configuration for PostCSS is found in .postcssrc.js
The configuration for Webpack is found in .webpackrc.js
Both PostCSS and Webpack use .browserslistrc
to decide on browser support when compiling.
hugo/static/
folder as they should appear in the built site
E.g, a CNAME file should be stored at hugo/static/CNAME
to become /CNAME
src/js/
to js/{filename}.js
require()
and import
statements from npm packages and local JS filessrc/css/
to css/{filename}.css
hugo/
folder are always committed{{ getenv "HUGO_ENV" }}
development
production
staging
This repository comes with basic example content pre-configured to work with Forestry, which you can use to start building your site.
hugo
All contributions are welcome! Please see our Code of Conduct & Support guidelines.
This boilerplate project is released under the MIT license.