Skip to main content

Getting Started

Published:

Prerequisites

  1. Install Hugo extended version, the minimum version is v0.164.0.
  2. Install Git version manager.
  3. Install Go, the minimum version is v1.20.0.

Installing Yore

  1. Create a site if you don't have one yet:

    hugo new site my-site --format yaml
    cd my-site

    Otherwise, cd into your existing project.

  2. Initialize your site as a Hugo module:

    hugo mod init github.com/username/repo  # or hugo mod init my-project
  3. Copy the configuration and paste it into hugo.yaml.

  4. Set up the language configurations.

    1. Change the defaultContentLanguage to your language.
    2. Find the top-level languages setting (directly below Language-specific configuration). Change the en block to your language.
    1. Change the defaultContentLanguage to your language.

    2. Replace the existing module field with the following configuration. In each mount, replace zh-cn and en with your own language codes, in both the source path and the matching matrix.languages value.

      module:
        imports:
          - path: github.com/ZhenShuo2021/hugo-yore
        mounts:
          - source: content/zh-cn
            target: content
            sites:
              matrix:
                languages: [zh-cn]  # matches languages.LANG (see next step)
          - source: content/en
            target: content
            sites:
              matrix:
                languages: [en]  # matches languages.LANG (see next step)
    3. Next, find the top-level languages setting (directly below Language-specific configuration). This is a separate setting from module.mounts above. Change each language block to match your site's languages.

  5. Initialize a Git repository in your project root:

    git init

    Copy the .gitignore below into your project root:

    # Hugo
    /public/
    /resources/_gen/
    jsconfig.json
    hugo_stats.json
    .hugo_build.lock
    
    # System
    .DS_Store
    
    # JS
    node_modules
    Already tracked?

    Use git rm -r --cached public/ resources/_gen/ to remove the files from Git tracking.

Preview Your Site

With the theme installed, create some sample pages to see how it looks:

hugo new content/_index.md
hugo new content/blog/_index.md
hugo new content/blog/first/index.md
hugo new content/blog/second/index.md
hugo new content/en/_index.md
hugo new content/en/blog/_index.md
hugo new content/en/blog/first/index.md
hugo new content/en/blog/second/index.md

Start the development server:

hugo server -DEF

View the site at http://localhost:1313/ and posts at http://localhost:1313/blog/. The browser reloads automatically on file save. Press Ctrl+C to stop the server.

Pages not found?

Hugo skips draft, expired, and future-dated posts by default. If a post is missing, check these three flags first:

  • -D builds draft posts, controlled by the draft field in front matter
  • -E builds expired posts, controlled by the expiryDate field in front matter
  • -F builds future posts, controlled by the date field in front matter

To avoid the draft issue entirely, remove draft from archetypes/default.md, the file that sets the default content for hugo new content.

Build Your Site

hugo server runs in the development environment. To build the site for production, use hugo build instead.

Keep Yore Updated

Since Yore is installed as a Hugo module, updating or pinning a version is a hugo mod command.

Update to the latest version:

hugo mod get -u github.com/ZhenShuo2021/hugo-yore
hugo mod tidy
git add go.mod go.sum
git commit -m "chore(deps): update hugo-yore"

To pin a specific version instead, replace -u with @vX.X.X:

hugo mod get github.com/ZhenShuo2021/hugo-yore@vX.X.X
hugo mod tidy
git add go.mod go.sum
git commit -m "chore(deps): pin hugo-yore to vX.X.X"

Article Connections

Accessibility settings

Font size