Install Book theme with the default configuration and the example site.
Version
Hugo 0.108
Create New Site
$ hugo new site my-book --format json
hugo new site
: create a new site with a default skeleton--format json
: use JSON as Hugo config format
Create NPM Config
$ cd my-book
$ npm init -y
Create an empty NPM config.
NPM Config
package.json
{
"name": "my-book",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"dev": "hugo server",
"build": "hugo --minify"
}
}
Line 5
"scripts": {
"dev": "hugo server",
"build": "hugo --minify"
}
dev
: run web server under development modebuild
: build HTML/CSS/JavaScript under production mode
Install Hugo Book Theme
$ git init
$ git submodule add https://github.com/alex-shpak/hugo-book themes/hugo-book
git init
:create a new git respositorygit submodule add
:install the Book theme as a git submodule
Hugo Config
config.json
{
"baseURL": "http://example.org/",
"languageCode": "en-us",
"title": "my-book",
"theme": "hugo-book"
}
theme
:sethugo-book
as the default theme
Enable Example Site
$ cp -R themes/hugo-book/exampleSite/content.en/* content
Copy all example markdowns to the content
folder.
Development Mode
$ npm run dev
Start web server under development mode.
Production Mode
$ npm run build
$ serve public
- Build HTML/CSS/JavaScript under production mode
- Start web server under production mode
Conclusion
- Install a Hugo theme as a git submodule to let the theme be updatable in the future
- Book theme provides an example under
exampleSite
folder