Getting Started with Hugo

Hugo 快速上手指南

Hugo Front matter

Step 1. Install Hugo

Go to Hugo releases and download the appropriate version for your OS and architecture.

$ hugo env
hugo v0.126.3+extended darwin/amd64 BuildDate=2024-06-02T13:02:43Z VendorInfo=brew
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.22.3"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"

Step 2. Launch Example Site

Hugo has its own example site which happens to also be the documentation site you are reading right now.

Follow the following steps:

  1. Clone the Hugo repository
  2. Go into the repo
  3. Copy example site files
  4. Run hugo in server mode
  5. Open your browser to http://localhost:1313

Corresponding pseudo commands:

git clone https://github.com/twotwo/hugo-template
cd hugo-template
cp -r themes/cleanwhite/exampleSite/* .
hugo server --disableFastRender -D

Once you’ve gotten here, follow along the rest of this page on your local build.

Step 3. Change content

Stop the Hugo process by hitting Ctrl+C.

Here 


we export WordPress posts into content

  1. Remove example posts
  2. Export WP content to Markdown files, use this script
  3. Run hugo in server mode

Corresponding pseudo commands:

rm -rf content/posts
python wp2octopress.py wp_lixinyang localhost user password /tmp/hugo-template/content/posts /tmp/hugo-template/content/pages
hugo server --disableFastRender -D

Change and save this file.. Notice what happened in your terminal.

 $ hugo server --disableFastRender -D
Watching for changes in /tmp/hugo-template/{archetypes,content,data,themes}
Watching for config changes in /tmp/hugo-template/hugo.yaml
Start building sites …

                   |  EN
-------------------+-------
  Pages            | 1018
  Paginator pages  |  336
  Non-page files   |    0
  Static files     |   73
  Processed images |    0
  Aliases          |  146
  Cleaned          |    0

Built in 859 ms

Refresh the browser and observe that the typo is now fixed.

Notice how quick that was. Try to refresh the site before it’s finished building. I double dare you. Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.

Step 4. Publish Service

Generate static site in public folder

$ hugo --minify --gc
$ rsync -avP public/* vps-server:local/path
Last updated on 2024-06-20 18:11
Built with Hugo