This article refers to the modern, up-to-date installation method of installing the theme locally as Hugo module. It describes how to install, upgrade the theme, and write new articles.
Proxy (optional)
If you’re located at China mainland without VPN, the Hugo module download may fail.
There are two proxies for this: GOPROXY.CN and GOPROXY.IO .
1$ go env -w GOPROXY=https://goproxy.cn,direct
or
1$ go env -w GOPROXY=https://goproxy.io,direct
Installation
Install a new site from scratch
Step 1: Create skeleton site
- Create and enter new site:
1$ hugo new site my-new-blog
2$ cd my-new-blog
Step 2: Turn your new site into a Hugo module:
1$ hugo mod init github.com/me/my-new-blog
Step 3: Declare hugo-theme-bootstrap module as a site dependency:
1$ hugo mod get github.com/razonyang/hugo-theme-bootstrap
Step 4 (optional): Copy example site content into your site
- Clone the
hugo-theme-bootstrap
repo into a temporary directory:
1$ git clone https://github.com/razonyang/hugo-theme-bootstrap /tmp/hugo-theme-bootstrap
If you’re using Windows, use
git clone https://github.com/razonyang/hugo-theme-bootstrap %temp%\hugo-theme-bootstrap
instead.
- Copy example site content:
1$ cp -a /tmp/hugo-theme-bootstrap/exampleSite/* .
If you’re using Windows, use
xcopy %TEMP%\hugo-theme-bootstrap\exampleSite /E
instead.
- Remove your file
config.toml
1rm config.toml
- Delete the repo from your temporary directory again:
1$ rm -rf /tmp/hugo-theme-bootstrap
At the top of your config/_default/config.toml
, switch the uncommented theme:
1# theme = "hugo-theme-bootstrap" # install via git submodule
2theme = "github.com/razonyang/hugo-theme-bootstrap" # install via hugo module
Step 5: Pull in dependencies via npm
- Use node package manager
npm
to pull in dependencies for this theme:
1$ hugo mod npm pack
2$ npm install
Step 6: Preview your site
- Start hugo’s built-in webserver to preview your website:
1$ hugo server
Install on an existing site
Step 1: Turn your existing site into a Hugo module:
1$ cd my-blog
2$ hugo mod init github.com/me/my-blog
Step 2: Declare hugo-theme-bootstrap module as a site dependency:
1$ hugo mod get github.com/razonyang/hugo-theme-bootstrap
Step 3 (optional): Copy example site content into your site
- Clone the
hugo-theme-bootstrap
repo into a temporary directory:
1$ git clone https://github.com/razonyang/hugo-theme-bootstrap /tmp/
- Copy example site configuration and content into your site:
1$ mkdir config
2$ cp -a /tmp/hugo-theme-bootstrap/exampleSite/config/* ./config
3$ cp -r /tmp/hugo-theme-bootstrap/exampleSite/content/about/ \
4 /tmp/hugo-theme-bootstrap/exampleSite/content/archives/ \
5 /tmp/hugo-theme-bootstrap/exampleSite/content/categories/ \
6 /tmp/hugo-theme-bootstrap/exampleSite/content/contact/ \
7 /tmp/hugo-theme-bootstrap/exampleSite/content/offline/ \
8 /tmp/hugo-theme-bootstrap/exampleSite/content/search/ \
9 /tmp/hugo-theme-bootstrap/exampleSite/content/series/ \
10 /tmp/hugo-theme-bootstrap/exampleSite/content/tags/ \
11 ./content
- Delete the repo from your temporary directory again:
1$ rm -rf /tmp/hugo-theme-bootstrap/
At the top of your config/_default/config.toml
, switch the uncommented theme:
1# theme = "hugo-theme-bootstrap" # install via git submodule
2theme = "github.com/razonyang/hugo-theme-bootstrap" # install via hugo module
Step 4: Pull in dependencies via npm
- Use node package manager
npm
to pull in dependencies for this theme:
1$ hugo mod npm pack
2$ npm install
Step 5: Preview your site
- Start hugo’s built-in webserver to preview your website:
1$ hugo server
Theme Upgrade
- Invoke hugo’s module
get
subcommand with the update flag:
1$ cd my-blog
2$ hugo mod get -u github.com/razonyang/hugo-theme-bootstrap
Hugo will automatically pull in the latest theme version.
If you want to set your module to a certain
version
inside thehugo-theme-bootstrap
theme repo, simply specific the name of the tag representing this version when updating your theme.
1$ hugo mod get -u github.com/razonyang/hugo-theme-bootstrap@version
Instead of a version tag, you can also specify a commit hash inside the repo (here:
de4a40f
) when updating your theme:
1$ hugo mod get -u github.com/razonyang/hugo-theme-bootstrap@de4a40f
Comments