Hugo installing Themes - Options
Theming Options, modules, git-submodules, or theme copy
Getting Started
step 0: install hugo & node
brew install hugo node
step 1: create a new blank hugo site
hugo new site yourproject
step 2: find a theme & fork (or directly clone it)
A good place to start is at: https://themes.gohugo.io/
Install The Theme
A few interesting themes (to me)
A - Hugo Modules
The officially preferred way. Some themes only allow this - ie: https://github.com/wowchemy/starter-hugo-academic
first update the config.yaml
file with:
module:
imports:
- path: "github.com/willfaught/paige"
Install the module:
cd yourproject
hugo mod init github.com/youraccount/yourproject
hugo mod get github.com/willfaught/paige
Get theme updates:
cd yourproject
hugo mod get -u
NOTE: I have had problems with some themes as they evolve their theme.
B - Git subtree
Subtrees Explained - (Easier than Git Submodule)
Example config.yaml
:
theme: "paige"
Install:
$ cd yourproject
$ git subtree add --prefix themes/paige --squash https://github.com/willfaught/paige master
Update:
$ cd yourproject
$ git subtree pull --prefix themes/paige --squash https://github.com/willfaught/paige master
C - Git submodule
Example config.yaml
:
theme: "paige"
Install:
$ cd yourproject
$ git submodule add https://github.com/willfaught/paige themes/paige
$ git submodule update --init --recursive --remote
Update:
$ cd yourproject
$ git submodule update --recursive --remote
NOTE: this turns out to be complex with CloudCannon and other web editors
D - copy the theme (and remove git config)
Example config.yaml
:
theme: "paige"
Install:
$ cd yourproject
$ git clone https://github.com/willfaught/paige themes/paige
$ rm -rf themes/paige/.git
Update:
$ cd yourproject
$ rm -rf themes/paige
$ git clone https://github.com/willfaught/paige themes/paige
$ rm -rf themes/paige/.git
Running
$ cd yourproject
$ hugo mod npm pack
$ npm install
$ hugo server -D