allconfig

package
v0.0.0-...-42d6f5d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

Package allconfig contains the full configuration for Hugo. <docsmeta>{ "name": "Configuration", "description": "This section holds all configuration options in Hugo." }</docsmeta>

Package allconfig contains the full configuration for Hugo.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConfigFile = errors.New("Unable to locate config file or config directory. Perhaps you need to create a new site.\n       Run `hugo help new` for details.\n")

Functions

This section is empty.

Types

type Config

type Config struct {
	// For internal use only.
	Internal InternalConfig `mapstructure:"-" json:"-"`
	// For internal use only.
	C *ConfigCompiled `mapstructure:"-" json:"-"`

	RootConfig

	// Author information.
	Author map[string]any

	// Social links.
	Social map[string]string

	// The build configuration section contains build-related configuration options.
	// <docsmeta>{"identifiers": ["build"] }</docsmeta>
	Build config.BuildConfig `mapstructure:"-"`

	// The caches configuration section contains cache-related configuration options.
	// <docsmeta>{"identifiers": ["caches"] }</docsmeta>
	Caches filecache.Configs `mapstructure:"-"`

	// The markup configuration section contains markup-related configuration options.
	// <docsmeta>{"identifiers": ["markup"] }</docsmeta>
	Markup markup_config.Config `mapstructure:"-"`

	// The mediatypes configuration section maps the MIME type (a string) to a configuration object for that type.
	// <docsmeta>{"identifiers": ["mediatypes"], "refs": ["types:media:type"] }</docsmeta>
	MediaTypes *config.ConfigNamespace[map[string]media.MediaTypeConfig, media.Types] `mapstructure:"-"`

	Imaging *config.ConfigNamespace[images.ImagingConfig, images.ImagingConfigInternal] `mapstructure:"-"`

	// The outputformats configuration sections maps a format name (a string) to a configuration object for that format.
	OutputFormats *config.ConfigNamespace[map[string]output.OutputFormatConfig, output.Formats] `mapstructure:"-"`

	// The outputs configuration section maps a Page Kind (a string) to a slice of output formats.
	// This can be overridden in the front matter.
	Outputs map[string][]string `mapstructure:"-"`

	// The cascade configuration section contains the top level front matter cascade configuration options,
	// a slice of page matcher and params to apply to those pages.
	Cascade *config.ConfigNamespace[[]page.PageMatcherParamsConfig, map[page.PageMatcher]maps.Params] `mapstructure:"-"`

	// Menu configuration.
	// <docsmeta>{"refs": ["config:languages:menus"] }</docsmeta>
	Menus *config.ConfigNamespace[map[string]navigation.MenuConfig, navigation.Menus] `mapstructure:"-"`

	// The deployment configuration section contains for hugo deploy.
	Deployment deploy.DeployConfig `mapstructure:"-"`

	// Module configuration.
	Module modules.Config `mapstructure:"-"`

	// Front matter configuration.
	Frontmatter pagemeta.FrontmatterConfig `mapstructure:"-"`

	// Minification configuration.
	Minify minifiers.MinifyConfig `mapstructure:"-"`

	// Permalink configuration.
	Permalinks map[string]map[string]string `mapstructure:"-"`

	// Taxonomy configuration.
	Taxonomies map[string]string `mapstructure:"-"`

	// Sitemap configuration.
	Sitemap config.SitemapConfig `mapstructure:"-"`

	// Related content configuration.
	Related related.Config `mapstructure:"-"`

	// Server configuration.
	Server config.Server `mapstructure:"-"`

	// Privacy configuration.
	Privacy privacy.Config `mapstructure:"-"`

	// Security configuration.
	Security security.Config `mapstructure:"-"`

	// Services configuration.
	Services services.Config `mapstructure:"-"`

	// User provided parameters.
	// <docsmeta>{"refs": ["config:languages:params"] }</docsmeta>
	Params maps.Params `mapstructure:"-"`

	// The languages configuration sections maps a language code (a string) to a configuration object for that language.
	Languages map[string]langs.LanguageConfig `mapstructure:"-"`

	// UglyURLs configuration. Either a boolean or a sections map.
	UglyURLs any `mapstructure:"-"`
}

func (*Config) CompileConfig

func (c *Config) CompileConfig(logger loggers.Logger) error

func (*Config) IsKindEnabled

func (c *Config) IsKindEnabled(kind string) bool

func (*Config) IsLangDisabled

func (c *Config) IsLangDisabled(lang string) bool

type ConfigCompiled

type ConfigCompiled struct {
	Timeout           time.Duration
	BaseURL           urls.BaseURL
	BaseURLLiveReload urls.BaseURL
	KindOutputFormats map[string]output.Formats
	DisabledKinds     map[string]bool
	DisabledLanguages map[string]bool
	IgnoredErrors     map[string]bool
	CreateTitle       func(s string) string
	IsUglyURLSection  func(section string) bool
	IgnoreFile        func(filename string) bool
	MainSections      []string
	Clock             time.Time
	// contains filtered or unexported fields
}

ConfigCompiled holds values and functions that are derived from the config.

func (*ConfigCompiled) SetBaseURL

func (c *ConfigCompiled) SetBaseURL(baseURL, baseURLLiveReload urls.BaseURL)

This is set after the config is compiled by the server command.

func (*ConfigCompiled) SetMainSectionsIfNotSet

func (c *ConfigCompiled) SetMainSectionsIfNotSet(sections []string)

This may be set after the config is compiled.

type ConfigLanguage

type ConfigLanguage struct {
	// contains filtered or unexported fields
}

func (ConfigLanguage) BaseConfig

func (c ConfigLanguage) BaseConfig() config.BaseConfig

func (ConfigLanguage) BaseURL

func (c ConfigLanguage) BaseURL() urls.BaseURL

func (ConfigLanguage) BaseURLLiveReload

func (c ConfigLanguage) BaseURLLiveReload() urls.BaseURL

func (ConfigLanguage) BuildDrafts

func (c ConfigLanguage) BuildDrafts() bool

func (ConfigLanguage) BuildExpired

func (c ConfigLanguage) BuildExpired() bool

func (ConfigLanguage) BuildFuture

func (c ConfigLanguage) BuildFuture() bool

func (ConfigLanguage) CanonifyURLs

func (c ConfigLanguage) CanonifyURLs() bool

func (ConfigLanguage) CreateTitle

func (c ConfigLanguage) CreateTitle(s string) string

func (ConfigLanguage) DefaultContentLanguage

func (c ConfigLanguage) DefaultContentLanguage() string

func (ConfigLanguage) DefaultContentLanguageInSubdir

func (c ConfigLanguage) DefaultContentLanguageInSubdir() bool

func (ConfigLanguage) Dirs

func (c ConfigLanguage) Dirs() config.CommonDirs

func (ConfigLanguage) DirsBase

func (c ConfigLanguage) DirsBase() config.CommonDirs

func (ConfigLanguage) DisablePathToLower

func (c ConfigLanguage) DisablePathToLower() bool

func (ConfigLanguage) EnableMissingTranslationPlaceholders

func (c ConfigLanguage) EnableMissingTranslationPlaceholders() bool

func (ConfigLanguage) Environment

func (c ConfigLanguage) Environment() string

func (ConfigLanguage) GetConfig

func (c ConfigLanguage) GetConfig() any

func (ConfigLanguage) GetConfigSection

func (c ConfigLanguage) GetConfigSection(s string) any

GetConfigSection is mostly used in tests. The switch statement isn't complete, but what's in use.

func (ConfigLanguage) IgnoreFile

func (c ConfigLanguage) IgnoreFile(s string) bool

func (ConfigLanguage) IgnoredErrors

func (c ConfigLanguage) IgnoredErrors() map[string]bool

func (ConfigLanguage) IsLangDisabled

func (c ConfigLanguage) IsLangDisabled(lang string) bool

func (ConfigLanguage) IsMultiLingual

func (c ConfigLanguage) IsMultiLingual() bool

func (ConfigLanguage) IsMultihost

func (c ConfigLanguage) IsMultihost() bool

func (ConfigLanguage) IsUglyURLs

func (c ConfigLanguage) IsUglyURLs(section string) bool

func (ConfigLanguage) Language

func (c ConfigLanguage) Language() *langs.Language

func (ConfigLanguage) LanguagePrefix

func (c ConfigLanguage) LanguagePrefix() string

func (ConfigLanguage) Languages

func (c ConfigLanguage) Languages() langs.Languages

func (ConfigLanguage) LanguagesDefaultFirst

func (c ConfigLanguage) LanguagesDefaultFirst() langs.Languages

func (ConfigLanguage) NewContentEditor

func (c ConfigLanguage) NewContentEditor() string

func (ConfigLanguage) NoBuildLock

func (c ConfigLanguage) NoBuildLock() bool

func (ConfigLanguage) Paginate

func (c ConfigLanguage) Paginate() int

func (ConfigLanguage) PaginatePath

func (c ConfigLanguage) PaginatePath() string

func (ConfigLanguage) PrintI18nWarnings

func (c ConfigLanguage) PrintI18nWarnings() bool

func (ConfigLanguage) PrintUnusedTemplates

func (c ConfigLanguage) PrintUnusedTemplates() bool

func (ConfigLanguage) Quiet

func (c ConfigLanguage) Quiet() bool

func (ConfigLanguage) RemovePathAccents

func (c ConfigLanguage) RemovePathAccents() bool

func (ConfigLanguage) Running

func (c ConfigLanguage) Running() bool

func (ConfigLanguage) StaticDirs

func (c ConfigLanguage) StaticDirs() []string

func (ConfigLanguage) SummaryLength

func (c ConfigLanguage) SummaryLength() int

func (ConfigLanguage) TemplateMetrics

func (c ConfigLanguage) TemplateMetrics() bool

func (ConfigLanguage) TemplateMetricsHints

func (c ConfigLanguage) TemplateMetricsHints() bool

func (ConfigLanguage) Timeout

func (c ConfigLanguage) Timeout() time.Duration

func (ConfigLanguage) WorkingDir

func (c ConfigLanguage) WorkingDir() string

type ConfigSourceDescriptor

type ConfigSourceDescriptor struct {
	Fs     afero.Fs
	Logger loggers.Logger

	// Config received from the command line.
	// These will override any config file settings.
	Flags config.Provider

	// Path to the config file to use, e.g. /my/project/config.toml
	Filename string

	// The (optional) directory for additional configuration files.
	ConfigDir string

	// production, development
	Environment string

	// Defaults to os.Environ if not set.
	Environ []string
}

ConfigSourceDescriptor describes where to find the config (e.g. config.toml etc.).

type Configs

type Configs struct {
	Base                *Config
	LoadingInfo         config.LoadConfigResult
	LanguageConfigMap   map[string]*Config
	LanguageConfigSlice []*Config

	IsMultihost           bool
	Languages             langs.Languages
	LanguagesDefaultFirst langs.Languages

	Modules       modules.Modules
	ModulesClient *modules.Client
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig(d ConfigSourceDescriptor) (*Configs, error)

func (Configs) ConfigLangs

func (c Configs) ConfigLangs() []config.AllProvider

func (Configs) GetByLang

func (c Configs) GetByLang(lang string) config.AllProvider

func (Configs) GetFirstLanguageConfig

func (c Configs) GetFirstLanguageConfig() config.AllProvider

func (*Configs) Init

func (c *Configs) Init() error

func (*Configs) IsZero

func (c *Configs) IsZero() bool

type InternalConfig

type InternalConfig struct {
	// Server mode?
	Running bool

	Quiet          bool
	Verbose        bool
	Clock          string
	Watch          bool
	LiveReloadPort int
}

InternalConfig is the internal configuration for Hugo, not read from any user provided config file.

type RootConfig

type RootConfig struct {

	// The base URL of the site.
	// Note that the default value is empty, but Hugo requires a valid URL (e.g. "https://example.com/") to work properly.
	// <docsmeta>{"identifiers": ["URL"] }</docsmeta>
	BaseURL string

	// Whether to build content marked as draft.X
	// <docsmeta>{"identifiers": ["draft"] }</docsmeta>
	BuildDrafts bool

	// Whether to build content with expiryDate in the past.
	// <docsmeta>{"identifiers": ["expiryDate"] }</docsmeta>
	BuildExpired bool

	// Whether to build content with publishDate in the future.
	// <docsmeta>{"identifiers": ["publishDate"] }</docsmeta>
	BuildFuture bool

	// Copyright information.
	Copyright string

	// The language to apply to content without any language indicator.
	DefaultContentLanguage string

	// By default, we put the default content language in the root and the others below their language ID, e.g. /no/.
	// Set this to true to put all languages below their language ID.
	DefaultContentLanguageInSubdir bool

	// Disable creation of alias redirect pages.
	DisableAliases bool

	// Disable lower casing of path segments.
	DisablePathToLower bool

	// Disable page kinds from build.
	DisableKinds []string

	// A list of languages to disable.
	DisableLanguages []string

	// Disable the injection of the Hugo generator tag on the home page.
	DisableHugoGeneratorInject bool

	// Disable live reloading in server mode.
	DisableLiveReload bool

	// Enable replacement in Pages' Content of Emoji shortcodes with their equivalent Unicode characters.
	// <docsmeta>{"identifiers": ["Content", "Unicode"] }</docsmeta>
	EnableEmoji bool

	// THe main section(s) of the site.
	// If not set, Hugo will try to guess this from the content.
	MainSections []string

	// Enable robots.txt generation.
	EnableRobotsTXT bool

	// When enabled, Hugo will apply Git version information to each Page if possible, which
	// can be used to keep lastUpdated in synch and to print version information.
	// <docsmeta>{"identifiers": ["Page"] }</docsmeta>
	EnableGitInfo bool

	// Enable to track, calculate and print metrics.
	TemplateMetrics bool

	// Enable to track, print and calculate metric hints.
	TemplateMetricsHints bool

	// Enable to disable the build lock file.
	NoBuildLock bool

	// A list of error IDs to ignore.
	IgnoreErrors []string

	// A list of regexps that match paths to ignore.
	// Deprecated: Use the settings on module imports.
	IgnoreFiles []string

	// Ignore cache.
	IgnoreCache bool

	// Enable to print greppable placeholders (on the form "[i18n] TRANSLATIONID") for missing translation strings.
	EnableMissingTranslationPlaceholders bool

	// Enable to panic on warning log entries. This may make it easier to detect the source.
	PanicOnWarning bool

	// The configured environment. Default is "development" for server and "production" for build.
	Environment string

	// The default language code.
	LanguageCode string

	// Enable if the site content has CJK language (Chinese, Japanese, or Korean). This affects how Hugo counts words.
	HasCJKLanguage bool

	// The default number of pages per page when paginating.
	Paginate int

	// The path to use when creating pagination URLs, e.g. "page" in /page/2/.
	PaginatePath string

	// Whether to pluralize default list titles.
	// Note that this currently only works for English, but you can provide your own title in the content file's front matter.
	PluralizeListTitles bool

	// Make all relative URLs absolute using the baseURL.
	// <docsmeta>{"identifiers": ["baseURL"] }</docsmeta>
	CanonifyURLs bool

	// Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
	RelativeURLs bool

	// Removes non-spacing marks from composite characters in content paths.
	RemovePathAccents bool

	// Whether to track and print unused templates during the build.
	PrintUnusedTemplates bool

	// Enable to print warnings for missing translation strings.
	PrintI18nWarnings bool

	// ENable to print warnings for multiple files published to the same destination.
	PrintPathWarnings bool

	// URL to be used as a placeholder when a page reference cannot be found in ref or relref. Is used as-is.
	RefLinksNotFoundURL string

	// When using ref or relref to resolve page links and a link cannot be resolved, it will be logged with this log level.
	// Valid values are ERROR (default) or WARNING. Any ERROR will fail the build (exit -1).
	RefLinksErrorLevel string

	// This will create a menu with all the sections as menu items and all the sections’ pages as “shadow-members”.
	SectionPagesMenu string

	// The length of text in words to show in a .Summary.
	SummaryLength int

	// The site title.
	Title string

	// The theme(s) to use.
	// See Modules for more a more flexible way to load themes.
	Theme []string

	// Timeout for generating page contents, specified as a duration or in seconds.
	Timeout string

	// The time zone (or location), e.g. Europe/Oslo, used to parse front matter dates without such information and in the time function.
	TimeZone string

	// Set titleCaseStyle to specify the title style used by the title template function and the automatic section titles in Hugo.
	// It defaults to AP Stylebook for title casing, but you can also set it to Chicago or Go (every word starts with a capital letter).
	TitleCaseStyle string

	// The editor used for opening up new content.
	NewContentEditor string

	// Don't sync modification time of files for the static mounts.
	NoTimes bool

	// Don't sync modification time of files for the static mounts.
	NoChmod bool

	// Clean the destination folder before a new build.
	// This currently only handles static files.
	CleanDestinationDir bool

	// A Glob pattern of module paths to ignore in the _vendor folder.
	IgnoreVendorPaths string

	config.CommonDirs `mapstructure:",squash"`

	// The odd constructs below are kept for backwards compatibility.
	// Deprecated: Use module mount config instead.
	StaticDir []string
	// Deprecated: Use module mount config instead.
	StaticDir0 []string
	// Deprecated: Use module mount config instead.
	StaticDir1 []string
	// Deprecated: Use module mount config instead.
	StaticDir2 []string
	// Deprecated: Use module mount config instead.
	StaticDir3 []string
	// Deprecated: Use module mount config instead.
	StaticDir4 []string
	// Deprecated: Use module mount config instead.
	StaticDir5 []string
	// Deprecated: Use module mount config instead.
	StaticDir6 []string
	// Deprecated: Use module mount config instead.
	StaticDir7 []string
	// Deprecated: Use module mount config instead.
	StaticDir8 []string
	// Deprecated: Use module mount config instead.
	StaticDir9 []string
	// Deprecated: Use module mount config instead.
	StaticDir10 []string
}

RootConfig holds all the top-level configuration options in Hugo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL