Static website built on Hugo (Victor Hugo) and Forrestsry.io
This is a boilerplate for using Hugo as a static site generator, Webpack as your asset pipeline and Forestry.io as the CMS.
This is setup to use SASS and Typescript for CSS and JavaScript compiling/transpiling.
This project is released under the MIT license. Please make sure you understand its implications and guarantees.
To run: git clone git submodule init git submodule update yarn install
yarn start
You need to have the latest/LTS node and yarn versions installed in order to use this Static Website builder.
Hugo is also required hugo
Next step, clone this repository and run:
yarn install
This will take some time and will install all packages necessary to run Hugo and its tasks.
Then clone the submodules and update.
git submodule init
git submodule update
While developing your website, use:
yarn start
or for developing your website with hugo server --buildDrafts --buildFuture
, use:
yarn run preview
Then visit http://localhost:1313/ - or a new browser windows popped-up already - to preview your new website. Webpack Dev Server will automatically reload the CSS or refresh the whole page, when stylesheets or content changes.
To build a static version of the website inside the /dist
folder, run:
yarn run build-local
See package.json for all tasks.
|--content // Pages and collections - ask if you need extra pages
|--data // YAML data files with any data for use in examples
|--layouts // This is where all templates go
| |--partials // This is where includes live
| |--index.html // The index page
|--static // Files in here ends up in the public folder
|--assets // Files that will pass through the asset pipeline
| |--sass // Webpack will bundle imported sass separately
| |--index.ts // index.ts is the webpack entry for your js assets
You can read more about Hugo's template language in their documentation here:
https://gohugo.io/templates/overview/
The most useful page there is the one about the available functions:
https://gohugo.io/templates/functions/
For assets that are completely static and don't need to go through the asset pipeline,
use the site/static
folder. Images, font-files, etc, all go there.
Files in the static folder end up in the web root. So a file called site/static/favicon.ico
will end up being available as /favicon.ico
and so on...
The assets/index.js
file is the entrypoint for webpack and will be built to /dist/main.js
To separate the development and production - aka build - stages, all tasks run with a node environment variable named either development
or production
.
You can access the environment variable inside the theme files with getenv "NODE_ENV"
. See the following example for a conditional statement:
{{ if eq (getenv "NODE_ENV") "development" }}You're in development!{{ end }}
All tasks starting with build set the environment variable to production
- the other will set it to development
.
Preview Todo
- Create a new site on Netlify and link the repository.
Now Netlify will build and deploy your site whenever you push to git.