Documentation ¶
Index ¶
- Variables
- func FromFileToMap(fs afero.Fs, filename string) (map[string]any, error)
- func GetNumWorkerMultiplier() int
- func GetStringSlicePreserveString(cfg Provider, key string) []string
- func IsValidConfigFilename(filename string) bool
- func RenameKeys(m map[string]any)
- func SetEnvVars(oldVars *[]string, keyValues ...string)
- func SplitEnvVar(v string) (string, string)
- type AllProvider
- type BaseConfig
- type BuildConfig
- type BuildStats
- type CacheBuster
- type CommonDirs
- type ConfigNamespace
- type Headers
- type LoadConfigResult
- type Provider
- func FromConfigString(config, configType string) (Provider, error)
- func FromFile(fs afero.Fs, filename string) (Provider, error)
- func FromTOMLConfigString(config string) Provider
- func LoadConfigFromDir(sourceFs afero.Fs, configDir, environment string) (Provider, []string, error)
- func New() Provider
- func NewFrom(params maps.Params) Provider
- type Redirect
- type Server
- type SitemapConfig
Constants ¶
This section is empty.
Variables ¶
var ( // See issue #8979 for context. // Hugo has always used config.toml etc. as the default config file name. // But hugo.toml is a more descriptive name, but we need to check for both. DefaultConfigNames = []string{"hugo", "config"} DefaultConfigNamesSet = make(map[string]bool) ValidConfigFileExtensions = []string{"toml", "yaml", "yml", "json"} )
var ( // ConfigRootKeysSet contains all of the config map root keys. ConfigRootKeysSet = map[string]bool{ "build": true, "caches": true, "cascade": true, "frontmatter": true, "languages": true, "imaging": true, "markup": true, "mediatypes": true, "menus": true, "minify": true, "module": true, "outputformats": true, "params": true, "permalinks": true, "related": true, "sitemap": true, "privacy": true, "security": true, "taxonomies": true, } // ConfigRootKeys is a sorted version of ConfigRootKeysSet. ConfigRootKeys []string )
Functions ¶
func FromFileToMap ¶
FromFileToMap is the same as FromFile, but it returns the config values as a simple map.
func GetNumWorkerMultiplier ¶
func GetNumWorkerMultiplier() int
GetNumWorkerMultiplier returns the base value used to calculate the number of workers to use for Hugo's parallel execution. It returns the value in HUGO_NUMWORKERMULTIPLIER OS env variable if set to a positive integer, else the number of logical CPUs.
func GetStringSlicePreserveString ¶
GetStringSlicePreserveString returns a string slice from the given config and key. It differs from the GetStringSlice method in that if the config value is a string, we do not attempt to split it into fields.
func IsValidConfigFilename ¶
IsValidConfigFilename returns whether filename is one of the supported config formats in Hugo.
func RenameKeys ¶
RenameKeys renames config keys in m recursively according to a global Hugo alias definition.
func SetEnvVars ¶
SetEnvVars sets vars on the form key=value in the oldVars slice.
func SplitEnvVar ¶
Types ¶
type AllProvider ¶
type AllProvider interface { Language() *langs.Language Languages() langs.Languages LanguagesDefaultFirst() langs.Languages LanguagePrefix() string BaseURL() urls.BaseURL BaseURLLiveReload() urls.BaseURL Environment() string IsMultihost() bool IsMultiLingual() bool NoBuildLock() bool BaseConfig() BaseConfig Dirs() CommonDirs Quiet() bool DirsBase() CommonDirs GetConfigSection(string) any GetConfig() any CanonifyURLs() bool DisablePathToLower() bool RemovePathAccents() bool IsUglyURLs(section string) bool DefaultContentLanguage() string DefaultContentLanguageInSubdir() bool IsLangDisabled(string) bool SummaryLength() int Paginate() int PaginatePath() string BuildExpired() bool BuildFuture() bool BuildDrafts() bool Running() bool PrintUnusedTemplates() bool EnableMissingTranslationPlaceholders() bool TemplateMetrics() bool TemplateMetricsHints() bool PrintI18nWarnings() bool CreateTitle(s string) string IgnoreFile(s string) bool NewContentEditor() string Timeout() time.Duration StaticDirs() []string IgnoredErrors() map[string]bool WorkingDir() string }
AllProvider is a sub set of all config settings.
type BaseConfig ¶
type BuildConfig ¶
type BuildConfig struct { UseResourceCacheWhen string // never, fallback, always. Default is fallback // When enabled, will collect and write a hugo_stats.json with some build // related aggregated data (e.g. CSS class names). // Note that this was a bool <= v0.115.0. BuildStats BuildStats // Can be used to toggle off writing of the IntelliSense /assets/jsconfig.js // file. NoJSConfigInAssets bool // Can used to control how the resource cache gets evicted on rebuilds. CacheBusters []CacheBuster }
BuildConfig holds some build related configuration.
func DecodeBuildConfig ¶
func DecodeBuildConfig(cfg Provider) BuildConfig
func (*BuildConfig) CompileConfig ¶
func (b *BuildConfig) CompileConfig(logger loggers.Logger) error
func (BuildConfig) MatchCacheBuster ¶
MatchCacheBuster returns the cache buster for the given path p, nil if none.
func (BuildConfig) UseResourceCache ¶
func (b BuildConfig) UseResourceCache(err error) bool
type BuildStats ¶
BuildStats configures if and what to write to the hugo_stats.json file.
func (BuildStats) Enabled ¶
func (w BuildStats) Enabled() bool
type CacheBuster ¶
type CacheBuster struct { // Trigger for files matching this regexp. Source string // Cache bust targets matching this regexp. // This regexp can contain group matches (e.g. $1) from the source regexp. Target string // contains filtered or unexported fields }
CacheBuster configures cache busting for assets.
func (*CacheBuster) CompileConfig ¶
func (c *CacheBuster) CompileConfig(logger loggers.Logger) error
type CommonDirs ¶
type CommonDirs struct { // The directory where Hugo will look for themes. ThemesDir string // Where to put the generated files. PublishDir string // The directory to put the generated resources files. This directory should in most situations be considered temporary // and not be committed to version control. But there may be cached content in here that you want to keep, // e.g. resources/_gen/images for performance reasons or CSS built from SASS when your CI server doesn't have the full setup. ResourceDir string // The project root directory. WorkingDir string // The root directory for all cache files. CacheDir string // The content source directory. // Deprecated: Use module mounts. ContentDir string // Deprecated: Use module mounts. // The data source directory. DataDir string // Deprecated: Use module mounts. // The layout source directory. LayoutDir string // Deprecated: Use module mounts. // The i18n source directory. I18nDir string // Deprecated: Use module mounts. // The archetypes source directory. ArcheTypeDir string // Deprecated: Use module mounts. // The assets source directory. AssetDir string }
type ConfigNamespace ¶
type ConfigNamespace[S, C any] struct { // SourceStructure represents the source configuration with any defaults applied. // This is used for documentation and printing of the configuration setup to the user. SourceStructure any // SourceHash is a hash of the source configuration before any defaults gets applied. SourceHash string // Config is the final configuration as used by Hugo. Config C }
ConfigNamespace holds a Hugo configuration namespace. The construct looks a little odd, but it's built to make the configuration elements both self-documenting and contained in a common structure.
func DecodeNamespace ¶
func (*ConfigNamespace[S, C]) MarshalJSON ¶
func (ns *ConfigNamespace[S, C]) MarshalJSON() ([]byte, error)
MarshalJSON marshals the source structure.
func (*ConfigNamespace[S, C]) Signature ¶
func (ns *ConfigNamespace[S, C]) Signature() S
Signature returns the signature of the source structure. Note that this is for documentation purposes only and SourceStructure may not always be cast to S (it's usually just a map).
type LoadConfigResult ¶
type LoadConfigResult struct { Cfg Provider ConfigFiles []string BaseConfig BaseConfig }
type Provider ¶
type Provider interface { GetString(key string) string GetInt(key string) int GetBool(key string) bool GetParams(key string) maps.Params GetStringMap(key string) map[string]any GetStringMapString(key string) map[string]string GetStringSlice(key string) []string Get(key string) any Set(key string, value any) Keys() []string Merge(key string, value any) SetDefaults(params maps.Params) SetDefaultMergeStrategy() WalkParams(walkFn func(params ...maps.KeyParams) bool) IsSet(key string) bool }
Provider provides the configuration settings for Hugo.
func FromConfigString ¶
FromConfigString creates a config from the given YAML, JSON or TOML config. This is useful in tests.
func FromTOMLConfigString ¶
func LoadConfigFromDir ¶
type Redirect ¶
type Server ¶
type Server struct { Headers []Headers Redirects []Redirect // contains filtered or unexported fields }
Config for the dev server.
func DecodeServer ¶
func (*Server) MatchHeaders ¶
func (s *Server) MatchHeaders(pattern string) []types.KeyValueStr
func (*Server) MatchRedirect ¶
type SitemapConfig ¶
type SitemapConfig struct { // The page change frequency. ChangeFreq string // The priority of the page. Priority float64 // The sitemap filename. Filename string }
SitemapConfig configures the sitemap to be generated.
func DecodeSitemap ¶
func DecodeSitemap(prototype SitemapConfig, input map[string]any) (SitemapConfig, error)