HUGO

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
Star

Что на этой странице

  • Module Config: Top level
  • Module Config: hugoVersion
  • Module Config: imports
  • Module Config: mounts
HUGO MODULES

Configure Modules

This page describes the configuration options for a module.

Module Config: Top level

config.
     
module:
  noProxy: none
  noVendor: ""
  private: '*.*'
  proxy: direct
  replacements: ""
[module]
  noProxy = "none"
  noVendor = ""
  private = "*.*"
  proxy = "direct"
  replacements = ""
{
   "module": {
      "noProxy": "none",
      "noVendor": "",
      "private": "*.*",
      "proxy": "direct",
      "replacements": ""
   }
}
noVendor
A optional Glob pattern matching module paths to skip when vendoring, e.g. “github.com/**”
proxy
Defines the proxy server to use to download remote modules. Default is direct, which means “git clone” and similar.
noProxy
Comma separated glob list matching paths that should not use the proxy configured above.
private
Comma separated glob list matching paths that should be treated as private.
replacements
A comma separated (or a slice) list of module path to directory replacement mapping, e.g. "github.com/bep/myprettytheme -> ../..,github.com/bep/shortcodes -> /some/path. This is mostly useful for temporary locally development of a module, and then it makes sense to set it as an OS environment variable, e.g: env HUGO_MODULE_REPLACEMENTS="github.com/bep/myprettytheme -> ../..". Any relative path is relate to themesDir, and 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

Большинство команд для Модулей Хьюго требует установки более новой версии Go (смотрите https://golang.org/dl/) и соответствующего VCS клиента (например, Git, смотрите https://git-scm.com/downloads/ ). Если у Вас есть «более старый» сайт, работающий на Netlify, Вам, возможно, придется установить GO_VERSION на 1.12 в настройках среды.

Для получения дополнительной информации о модулях Go, смотрите:

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

Module Config: 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.

config.
     
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
The minimum Hugo version supported, e.g. 0.55.0
max
The maximum Hugo version supported, e.g. 0.55.0
extended
Whether the extended version of Hugo is required.

Module Config: imports

config.
     
module:
  imports:
  - disable: false
    ignoreConfig: false
    path: github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v
  - path: my-shortcodes
[module]

  [[module.imports]]
    disable = false
    ignoreConfig = false
    path = "github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v"

  [[module.imports]]
    path = "my-shortcodes"
{
   "module": {
      "imports": [
         {
            "disable": false,
            "ignoreConfig": 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. config.toml, will not be loaded. Note that this will also stop the loading of any transitive module dependencies.
disable
Set to true to disable the module while keeping any version info in the go.* files.

Большинство команд для Модулей Хьюго требует установки более новой версии Go (смотрите https://golang.org/dl/) и соответствующего VCS клиента (например, Git, смотрите https://git-scm.com/downloads/ ). Если у Вас есть «более старый» сайт, работающий на Netlify, Вам, возможно, придется установить GO_VERSION на 1.12 в настройках среды.

Для получения дополнительной информации о модулях Go, смотрите:

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

Module Config: mounts

When the mounts config was introduced in Hugo 0.56.0, we were careful to preserve the existing 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 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

config.
     
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
The source directory of the mount. For the main project, this can be either project-relative or absolute and even a symbolic link. For other modules it must be project-relative.
target
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.
lang
The language code, e.g. “en”. Only relevant for content mounts, and static mounts when in multihost mode.

Смотрите также

  • Use Hugo Modules
  • Theme Components
  • Directory Structure
  • Static Files
  • Add Your Hugo Theme to the Showcase
  • About Hugo
    • Overview
    • Hugo's Security Model
    • Hugo and GDPR
    • What is Hugo
    • Hugo Features
    • The Benefits of Static
    • License
  • Getting Started
    • Get Started Overview
    • Quick Start
    • Install Hugo
    • Basic Usage
    • Directory Structure
    • Configuration
    • External Learning Resources
  • Hugo Modules
    • Hugo Modules Overview
    • Configure Modules
    • Use Hugo Modules
    • Theme Components
  • Content Management
    • Content Management Overview
    • Organization
    • Page Bundles
    • Content Formats
    • Front Matter
    • Build Options
    • Page Resources
    • Image Processing
    • Shortcodes
    • Related Content
    • Sections
    • Content Types
    • Archetypes
    • Taxonomies
    • Summaries
    • Links and Cross References
    • URL Management
    • Menus
    • Static Files
    • Table of Contents
    • Comments
    • Multilingual and i18n
    • Syntax Highlighting
  • Templates
    • Templates Overview
    • Introduction
    • Template Lookup Order
    • Custom Output Formats
    • Base Templates and Blocks
    • List Page Templates
    • Homepage Template
    • Section Templates
    • Taxonomy Templates
    • Single Page Templates
    • Content View Templates
    • Data Templates
    • Partial Templates
    • Shortcode Templates
    • Local File Templates
    • 404 Page
    • Menu Templates
    • Pagination
    • RSS Templates
    • Sitemap Template
    • Robots.txt
    • Internal Templates
    • Alternative Templating
    • Template Debugging
  • Functions
    • Functions Quick Reference
    • .AddDate
    • .Format
    • .Get
    • .GetPage
    • .HasMenuCurrent
    • .IsMenuCurrent
    • .Param
    • .Render
    • .RenderString
    • .Scratch
    • .Unix
    • absLangURL
    • absURL
    • after
    • anchorize
    • append
    • apply
    • base64
    • chomp
    • complement
    • cond
    • countrunes
    • countwords
    • dateFormat
    • default
    • delimit
    • dict
    • echoParam
    • emojify
    • eq
    • errorf and warnf
    • fileExists
    • findRE
    • first
    • float
    • ge
    • getenv
    • group
    • gt
    • hasPrefix
    • highlight
    • hmac
    • htmlEscape
    • htmlUnescape
    • hugo
    • humanize
    • i18n
    • Image Functions
    • in
    • index
    • int
    • intersect
    • isset
    • jsonify
    • lang.Merge
    • lang.NumFmt
    • last
    • le
    • len
    • lower
    • lt
    • markdownify
    • Math
    • md5
    • merge
    • ne
    • now
    • os.Stat
    • partialCached
    • path.Base
    • path.Dir
    • path.Ext
    • path.Join
    • path.Split
    • plainify
    • pluralize
    • print
    • printf
    • println
    • querify
    • range
    • readDir
    • readFile
    • ref
    • reflect.IsMap
    • reflect.IsSlice
    • relLangURL
    • relref
    • relURL
    • replace
    • replaceRE
    • safeCSS
    • safeHTML
    • safeHTMLAttr
    • safeJS
    • safeURL
    • seq
    • sha
    • shuffle
    • singularize
    • slice
    • slicestr
    • sort
    • split
    • string
    • strings.Count
    • strings.HasSuffix
    • strings.Repeat
    • strings.RuneCount
    • strings.TrimLeft
    • strings.TrimPrefix
    • strings.TrimRight
    • strings.TrimSuffix
    • substr
    • symdiff
    • templates.Exists
    • time
    • title
    • transform.Unmarshal
    • trim
    • truncate
    • union
    • uniq
    • upper
    • urlize
    • urls.Parse
    • where
    • with
  • Variables
    • Variables Overview
    • Site Variables
    • Page Variables
    • Shortcode Variables
    • Pages Methods
    • Taxonomy Variables
    • File Variables
    • Menu Entry Properties
    • Hugo Variables
    • Git Variables
    • Sitemap Variables
  • Hugo Pipes
    • Hugo Pipes Overview
    • Hugo Pipes Introduction
    • SASS / SCSS
    • PostProcess
    • PostCSS
    • JavaScript Building
    • Babel
    • Asset minification
    • Asset bundling
    • Fingerprinting and SRI
    • Resource from Template
    • Resource from String
  • CLI
  • Troubleshooting
    • Troubleshoot
    • FAQ
    • Build Performance
  • Tools
    • Developer Tools Overview
    • Migrations
    • Starter Kits
    • Frontends
    • Editor Plug-ins
    • Search
    • Other Projects
  • Hosting & Deployment
    • Hosting & Deployment Overview
    • Hugo Deploy
    • Host-Agnostic Deploys with Nanobox
    • Host on AWS Amplify
    • Host on Netlify
    • Host on Render
    • Host on Firebase
    • Host on GitHub
    • Host on GitLab
    • Hosting on KeyCDN
    • Host on Bitbucket
    • Deployment with Wercker
    • Deployment with Rsync
  • Contribute
    • Contribute to Hugo
    • Development
    • Documentation
    • Themes
  • Maintenance
“Configure Modules” последнее обновление: October 30, 2020: Update configuration.md (5a15be93d)
Улучшить эту страницу
Авторы Hugo
Hugo Logo
  • Подать вопрос
  • Получить помощь
  • Обсудить исходный код
  • @GoHugoIO
  • @spf13
  • @bepsays
 
 

Спонсоры Hugo

Logo for Forestry.io
Logo for Linode
Logo for eSolia
 

Авторские права на логотипы Hugo принадлежат © Steve Francia 2013–2021.

Hugo Gopher основан на оригинальной работе Renée French.

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
  • About Hugo
  • Getting Started
  • Hugo Modules
  • Content Management
  • Templates
  • Functions
  • Variables
  • Hugo Pipes
  • CLI
  • Troubleshooting
  • Tools
  • Hosting & Deployment
  • Contribute
  • Maintenance