HUGO ja 非公式

  • ニュース
  • ドキュメント
  • テーマ
  • コミュニティ
  • GitHub
gohugoio Star づけ
  暫定公開中 2024/09/16 (94d7f576a 対応, 2024/09/15)
  • Hugo について
    • 本節
    • Introduction
    • Hugo の機能
    • Privacy
    • セキュリティ
    • ライセンス
  • インストール
    • 本節
    • macOS
    • Linux
    • Windows
    • BSD
  • はじめよう
    • 本節
    • クイックスタート
    • ディレクトリ構造
    • 基本操作
    • 設定
    • Configure markup
    • 用語集
    • 本書以外の学習リソース
  • クイックリファレンス
    • 本節
    • Emojis
    • Functions
    • Methods
    • Page collections
  • コンテント管理
    • 本節
    • コンテントの構成
    • ページバンドル
    • コンテントフォーマット
    • フロントマター
    • ビルドオプション
    • ページリソース
    • イメージ処理
    • ショートコード
    • 関連コンテント
    • Sections
    • Content types
    • アーキタイプ
    • 分類
    • Summaries
    • Links and cross references
    • URL 管理
    • メニュー
    • コメント
    • マルチ言語
    • Markdown attributes
    • シンタックスハイライト
    • Diagrams
    • Mathematics
    • Data sources
    • Content adapters
  • テンプレート
    • 本節
    • はじめに
    • Template types
    • Lookup order
    • 基本テンプレート
    • Home templates
    • Single templates
    • Section templates
    • Taxonomy templates
    • Term templates
    • 部分テンプレート
    • コンテントビューテンプレート
    • ショートコードテンプレート
    • サイトマップテンプレート
    • RSS テンプレート
    • 404 テンプレート
    • robots.txt templates
    • メニュー
    • ページネーション
    • Embedded templates
    • Custom output formats
  • 関数
    • 本節
    • cast
    • collections
    • compare
    • crypto
    • css
    • data
    • debug
    • diagrams
    • encoding
    • fmt
    • global
    • go template
    • hash
    • hugo
    • images
    • inflect
    • js
    • lang
    • math
    • openapi3
    • os
    • partials
    • path
    • reflect
    • resources
    • safe
    • strings
    • templates
    • time
    • transform
    • urls
  • メソッド
    • 本節
    • Duration
    • Menu
    • Menu entry
    • Page
    • Pager
    • Pages
    • Resource
    • Shortcode
    • Site
    • Taxonomy
    • Time
  • レンダーフック
    • 本節
    • Introduction
    • Blockquotes
    • Code blocks
    • Headings
    • Images
    • Links
    • Passthrough
    • Tables
  • Hugo モジュール
    • In this section
    • Configure Hugo modules
    • Use Hugo Modules
    • Theme components
  • Hugo パイプ
    • 本節
    • Introduction
    • Transpile Sass to CSS
    • PostCSS
    • PostProcess
    • JavaScript building
    • Babel
    • Asset minification
    • Concatenating assets
    • Fingerprinting and SRI hashing
    • Resource from string
    • Resource from template
  • CLI
  • トラブルシューティング
    • 本節
    • Logging
    • Inspection
    • Deprecation
    • Performance
    • FAQs
  • 開発ツール
    • 本節
    • Editor plugins
    • Front-ends
    • 検索
    • Migrations
    • Other projects
  • ホスティングと開発
    • 本節
    • Hugo Deploy
    • Deploy with Rclone
    • Deploy with Rsync
    • Host on 21YunBox
    • Host on AWS Amplify
    • Host on Azure Static Web Apps
    • Host on Cloudflare Pages
    • Host on Firebase
    • Host on GitHub Pages
    • Host on GitLab Pages
    • Host on KeyCDN
    • Host on Netlify
    • Host on Render
  • 貢献
    • 本節
    • Development
    • ドキュメント
    • Themes
  • メンテナンス
Hugo モジュール

Configure Hugo modules

This page describes the configuration options for a module.

Module configuration: top level

hugo.
     
module:
  noProxy: none
  noVendor: ""
  private: '*.*'
  proxy: direct
  replacements: ""
  vendorClosest: false
  workspace: "off"
[module]
  noProxy = 'none'
  noVendor = ''
  private = '*.*'
  proxy = 'direct'
  replacements = ''
  vendorClosest = false
  workspace = 'off'
{
   "module": {
      "noProxy": "none",
      "noVendor": "",
      "private": "*.*",
      "proxy": "direct",
      "replacements": "",
      "vendorClosest": false,
      "workspace": "off"
   }
}
noProxy
(string) Comma separated glob list matching paths that should not use the proxy configured above.
noVendor
(string) A optional Glob pattern matching module paths to skip when vendoring, e.g. “github.com/**”
private
(string) Comma separated glob list matching paths that should be treated as private.
proxy
(string) Defines the proxy server to use to download remote modules. Default is direct, which means “git clone” and similar.
vendorClosest
(bool) When enabled, we will pick the vendored module closest to the module using it. The default behavior is to pick the first. Note that there can still be only one dependency of a given module path, so once it is in use it cannot be redefined. Default is false.
workspace
(string) The workspace file to use. This enables Go workspace mode. Note that this can also be set via OS env, e.g. export HUGO_MODULE_WORKSPACE=/my/hugo.work This only works with Go 1.18+. In Hugo v0.109.0 we changed the default to off and we now resolve any relative work file names relative to the working directory.
replacements
(string) A comma-separated list of mappings from module paths to directories, e.g. github.com/bep/my-theme -> ../..,github.com/bep/shortcodes -> /some/path. This is mostly useful for temporary local development of a module, in which case you might want to save it as an environment variable, e.g: env HUGO_MODULE_REPLACEMENTS="github.com/bep/my-theme -> ../..". Relative paths are relative to themesDir. Absolute paths are allowed.

Note that the above terms maps directly to their counterparts in Go Modules. Some of these setting may be natural to set as OS environment variables. To set the proxy server to use, as an example:

env HUGO_MODULE_PROXY=https://proxy.example.org hugo

Most of the commands for Hugo Modules require a newer version (>= 1.18) of Go installed (see https://golang.org/dl/) and the relevant VCS client (e.g. Git, see https://git-scm.com/downloads/ ). If you have an “older” site running on Netlify, you may have to set GO_VERSION to 1.19 or newer in your Environment settings.

For more information about Go Modules, see:

  • https://github.com/golang/go/wiki/Modules
  • https://blog.golang.org/using-go-modules

Module configuration: hugoVersion

If your module requires a particular version of Hugo to work, you can indicate that in the module section and the user will be warned if using a too old/new version.

hugo.
     
module:
  hugoVersion:
    extended: false
    max: ""
    min: ""
[module]
  [module.hugoVersion]
    extended = false
    max = ''
    min = ''
{
   "module": {
      "hugoVersion": {
         "extended": false,
         "max": "",
         "min": ""
      }
   }
}

Any of the above can be omitted.

min
(string) The minimum Hugo version supported, e.g. 0.55.0
max
(string) The maximum Hugo version supported, e.g. 0.55.0
extended
(bool) Whether the extended version of Hugo is required.

Module configuration: imports

hugo.
     
module:
  imports:
  - disable: false
    ignoreConfig: false
    ignoreImports: false
    path: github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v
  - path: my-shortcodes
[module]
  [[module.imports]]
    disable = false
    ignoreConfig = false
    ignoreImports = false
    path = 'github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v'
  [[module.imports]]
    path = 'my-shortcodes'
{
   "module": {
      "imports": [
         {
            "disable": false,
            "ignoreConfig": false,
            "ignoreImports": false,
            "path": "github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v"
         },
         {
            "path": "my-shortcodes"
         }
      ]
   }
}
path
Can be either a valid Go Module module path, e.g. github.com/gohugoio/myShortcodes, or the directory name for the module as stored in your themes folder.
ignoreConfig
If enabled, any module configuration file, e.g. hugo.toml, will not be loaded. Note that this will also stop the loading of any transitive module dependencies.
ignoreImports
If enabled, module imports will not be followed.
disable
Set to true to disable the module while keeping any version info in the go.* files.
noMounts
Do not mount any folder in this import.
noVendor
Never vendor this import (only allowed in main project).

Most of the commands for Hugo Modules require a newer version (>= 1.18) of Go installed (see https://golang.org/dl/) and the relevant VCS client (e.g. Git, see https://git-scm.com/downloads/ ). If you have an “older” site running on Netlify, you may have to set GO_VERSION to 1.19 or newer in your Environment settings.

For more information about Go Modules, see:

  • https://github.com/golang/go/wiki/Modules
  • https://blog.golang.org/using-go-modules

Module configuration: mounts

When the mounts configuration was introduced in Hugo 0.56.0, we were careful to preserve the existing contentDir, staticDir, and similar configuration to make sure all existing sites just continued to work. But you should not have both: if you add a mounts section you should remove the old contentDir, staticDir, etc. settings.

When you add a mount, the default mount for the concerned target root is ignored: be sure to explicitly add it.

Default mounts

hugo.
     
module:
  mounts:
  - source: content
    target: content
  - source: static
    target: static
  - source: layouts
    target: layouts
  - source: data
    target: data
  - source: assets
    target: assets
  - source: i18n
    target: i18n
  - source: archetypes
    target: archetypes
[module]
  [[module.mounts]]
    source = 'content'
    target = 'content'
  [[module.mounts]]
    source = 'static'
    target = 'static'
  [[module.mounts]]
    source = 'layouts'
    target = 'layouts'
  [[module.mounts]]
    source = 'data'
    target = 'data'
  [[module.mounts]]
    source = 'assets'
    target = 'assets'
  [[module.mounts]]
    source = 'i18n'
    target = 'i18n'
  [[module.mounts]]
    source = 'archetypes'
    target = 'archetypes'
{
   "module": {
      "mounts": [
         {
            "source": "content",
            "target": "content"
         },
         {
            "source": "static",
            "target": "static"
         },
         {
            "source": "layouts",
            "target": "layouts"
         },
         {
            "source": "data",
            "target": "data"
         },
         {
            "source": "assets",
            "target": "assets"
         },
         {
            "source": "i18n",
            "target": "i18n"
         },
         {
            "source": "archetypes",
            "target": "archetypes"
         }
      ]
   }
}
source
(string) The source directory of the mount. For the main project, this can be either project-relative or absolute. For other modules it must be project-relative.
target
(string) Where it should be mounted into Hugo’s virtual filesystem. It must start with one of Hugo’s component folders: static, content, layouts, data, assets, i18n, or archetypes. E.g. content/blog.
disableWatch
v0.128.0 の新機能
(bool) Whether to disable watching in watch mode for this mount. Default is false.
lang
(string) The language code, e.g. “en”. Only relevant for content mounts, and static mounts when in multihost mode.
includeFiles
(string or string slice) One or more glob patterns matching files or directories to include. If excludeFiles is not set, the files matching includeFiles will be the files mounted.

The glob patterns are matched to the file names starting from the source root, they should have Unix styled slashes even on Windows, / matches the mount root and ** can be used as a super-asterisk to match recursively down all directories, e.g /posts/**.jpg.

The search is case-insensitive.

excludeFiles
(string or string slice) One or more glob patterns matching files to exclude.

Example

hugo.
     
module:
  mounts:
  - excludeFiles: docs/*
    source: content
    target: content
  - source: node_modules
    target: assets
  - source: assets
    target: assets
[module]
  [[module.mounts]]
    excludeFiles = 'docs/*'
    source = 'content'
    target = 'content'
  [[module.mounts]]
    source = 'node_modules'
    target = 'assets'
  [[module.mounts]]
    source = 'assets'
    target = 'assets'
{
   "module": {
      "mounts": [
         {
            "excludeFiles": "docs/*",
            "source": "content",
            "target": "content"
         },
         {
            "source": "node_modules",
            "target": "assets"
         },
         {
            "source": "assets",
            "target": "assets"
         }
      ]
   }
}

関連項目

  • Theme components
  • Use Hugo Modules
  • Alphabetical
  • AlternativeOutputFormats
  • Blockquote render hooks

このページ内

  • Module configuration: top level
  • Module configuration: hugoVersion
  • Module configuration: imports
  • Module configuration: mounts
最終更新日付: 0001/01/01
ページの変更
Hugo 作者より
Hugo Logo
  • Issue 報告
  • ヘルプ
  • @GoHugoIO
  • @spf13
  • @bepsays
 

Hugo Sponsors

Route4Me
Your Company?
 

The Hugo logos are copyright © Steve Francia 2013–2024.

The Hugo Gopher is based on an original work by Renée French.

  • ニュース
  • ドキュメント
  • テーマ
  • コミュニティ
  • GitHub
  • Hugo について
  • インストール
  • はじめよう
  • クイックリファレンス
  • コンテント管理
  • テンプレート
  • 関数
  • メソッド
  • レンダーフック
  • Hugo モジュール
  • Hugo パイプ
  • CLI
  • トラブルシューティング
  • 開発ツール
  • ホスティングと開発
  • 貢献
  • メンテナンス