Documentation
¶
Index ¶
- Constants
- Variables
- func CheckConfigFilename(dir string, fs afero.Fs) (string, bool)
- func DecodeLanguageConfig(p config.Provider) (map[string]LanguageConfig, error)
- func DecodeMenuConfig(cfg config.Provider) (map[string][]MenuConfig, error)
- func FromFile(fs afero.Fs, filename string) (config.Provider, error)
- func GetCacheDir(fs afero.Fs, cacheDir string) (string, error)
- func LoadConfigFromFile(fs afero.Fs, filename string) (map[string]any, error)
- func NewDefaultProvider() config.Provider
- func NewFrom(params maps.Params) config.Provider
- type BaseDirs
- type CachesConfig
- type CommonDirs
- type DefaultConfigProvider
- func (c *DefaultConfigProvider) Get(k string) any
- func (c *DefaultConfigProvider) GetBool(k string) bool
- func (c *DefaultConfigProvider) GetInt(k string) int
- func (c *DefaultConfigProvider) GetParams(k string) maps.Params
- func (c *DefaultConfigProvider) GetString(k string) string
- func (c *DefaultConfigProvider) GetStringMap(k string) map[string]any
- func (c *DefaultConfigProvider) GetStringMapString(k string) map[string]string
- func (c *DefaultConfigProvider) GetStringSlice(k string) []string
- func (c *DefaultConfigProvider) IsSet(k string) bool
- func (c *DefaultConfigProvider) Keys() []string
- func (c *DefaultConfigProvider) Merge(k string, v any)
- func (c *DefaultConfigProvider) Set(k string, v any)
- func (c *DefaultConfigProvider) SetDefaultMergeStrategy()
- func (c *DefaultConfigProvider) SetDefaults(params maps.Params)
- func (c *DefaultConfigProvider) WalkParams(walkFn func(params ...maps.KeyParams) bool)
- type Disqus
- type ExifConfig
- type FileCacheConfig
- type Funcs
- type GoogleAnalytics
- type HTTP
- type ImagingConfig
- type ImagingConfigInternal
- type Import
- type Instagram
- type LanguageConfig
- type MediaTypeConfig
- type MenuConfig
- type MinifyConfig
- type ModuleConfig
- type Mount
- type OutputFormatConfig
- type OutputFormatsConfig
- type RSS
- type RootConfig
- type SecurityConfig
- type ServiceConfig
- type SitemapConfig
- type TdewolffConfig
- type Twitter
- type ViewName
- type Vimeo
- type YouTube
Constants ¶
const (
FilecacheRootDirname = "filecache"
)
Variables ¶
var DefaultLanguage = LanguageConfig{ LanguageName: "English", LanguageCode: "en", Title: "", LanguageDirection: "", Weight: 0, Disabled: false, }
var DefaultSecurityConfig = SecurityConfig{ Auth: hexec.Auth{ Allow: security.MustNewWhitelist( "^(dart-)?sass(-embedded)?$", "^go$", "^npx$", "^postcss$", ), OsEnv: security.MustNewWhitelist(`(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE)$`), }, Funcs: Funcs{ Getenv: security.MustNewWhitelist("^HUGO_", "^CI$"), }, HTTP: HTTP{ URLs: security.MustNewWhitelist(".*"), Methods: security.MustNewWhitelist("(?i)GET|POST"), }, }
DefaultSecurityConfig holds the default security policy.
var EmptyModuleConfig = ModuleConfig{ Mounts: make([]Mount, 0), Imports: make([]Import, 0), }
Functions ¶
func DecodeLanguageConfig ¶
func DecodeLanguageConfig(p config.Provider) (map[string]LanguageConfig, error)
func DecodeMenuConfig ¶
func DecodeMenuConfig(cfg config.Provider) (map[string][]MenuConfig, error)
func GetCacheDir ¶
GetCacheDir returns a cache dir from the given filesystem and config. The dir will be created if it does not exist.
func LoadConfigFromFile ¶
func NewDefaultProvider ¶
NewDefaultProvider creates a Provider backed by an empty maps.Params.
Types ¶
type CachesConfig ¶
type CachesConfig map[string]FileCacheConfig
func DecodeCachesConfig ¶
func (CachesConfig) CacheDirModules ¶
func (c CachesConfig) CacheDirModules() string
type CommonDirs ¶
type CommonDirs struct {
BaseDirs `mapstructure:",squash"`
// 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 content source directory.
ContentDir string
// The data source directory.
DataDir string
// The layout source directory.
LayoutDir string
// The i18n source directory.
I18nDir string
// The archetypes source directory.
ArcheTypeDir string
// The assets source directory.
AssetsDir string
}
func (CommonDirs) GetDirectoryByName ¶
func (dirs CommonDirs) GetDirectoryByName(folderName string) string
type DefaultConfigProvider ¶
DefaultConfigProvider is a Provider backed by a map where all keys are lower case. All methods are thread safe.
func (*DefaultConfigProvider) Get ¶
func (c *DefaultConfigProvider) Get(k string) any
func (*DefaultConfigProvider) GetBool ¶
func (c *DefaultConfigProvider) GetBool(k string) bool
func (*DefaultConfigProvider) GetInt ¶
func (c *DefaultConfigProvider) GetInt(k string) int
func (*DefaultConfigProvider) GetParams ¶
func (c *DefaultConfigProvider) GetParams(k string) maps.Params
func (*DefaultConfigProvider) GetString ¶
func (c *DefaultConfigProvider) GetString(k string) string
func (*DefaultConfigProvider) GetStringMap ¶
func (c *DefaultConfigProvider) GetStringMap(k string) map[string]any
func (*DefaultConfigProvider) GetStringMapString ¶
func (c *DefaultConfigProvider) GetStringMapString(k string) map[string]string
func (*DefaultConfigProvider) GetStringSlice ¶
func (c *DefaultConfigProvider) GetStringSlice(k string) []string
func (*DefaultConfigProvider) IsSet ¶
func (c *DefaultConfigProvider) IsSet(k string) bool
func (*DefaultConfigProvider) Keys ¶
func (c *DefaultConfigProvider) Keys() []string
func (*DefaultConfigProvider) Merge ¶
func (c *DefaultConfigProvider) Merge(k string, v any)
func (*DefaultConfigProvider) Set ¶
func (c *DefaultConfigProvider) Set(k string, v any)
func (*DefaultConfigProvider) SetDefaultMergeStrategy ¶
func (c *DefaultConfigProvider) SetDefaultMergeStrategy()
func (*DefaultConfigProvider) SetDefaults ¶
func (c *DefaultConfigProvider) SetDefaults(params maps.Params)
SetDefaults will set values from params if not already set.
func (*DefaultConfigProvider) WalkParams ¶
func (c *DefaultConfigProvider) WalkParams(walkFn func(params ...maps.KeyParams) bool)
type Disqus ¶
type Disqus struct {
// A Shortname is the unique identifier assigned to a Disqus site.
Shortname string
// contains filtered or unexported fields
}
Disqus holds the privacy configuration settings related to the Disqus template.
type ExifConfig ¶
type ExifConfig struct {
// Regexp matching the Exif fields you want from the (massive) set of Exif info
// available. As we cache this info to disk, this is for performance and
// disk space reasons more than anything.
// If you want it all, put ".*" in this config setting.
// Note that if neither this or ExcludeFields is set, Hugo will return a small
// default set.
IncludeFields string
// Regexp matching the Exif fields you want to exclude. This may be easier to use
// than IncludeFields above, depending on what you want.
ExcludeFields string
// Hugo extracts the "photo taken" date/time into .Date by default.
// Set this to true to turn it off.
DisableDate bool
// Hugo extracts the "photo taken where" (GPS latitude and longitude) into
// .Long and .Lat. Set this to true to turn it off.
DisableLatLong bool
}
type FileCacheConfig ¶
type FileCacheConfig struct {
// Max age of cache entries in this cache. Any items older than this will
// be removed and not returned from the cache.
// A negative value means forever, 0 means cache is disabled.
// Hugo is lenient with what types it accepts here, but we recommend using
// a duration string, a sequence of decimal numbers, each with optional fraction and a unit suffix,
// such as "300ms", "1.5h" or "2h45m".
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
MaxAge time.Duration
// The directory where files are stored.
Dir string
DirCompiled string `json:"-"`
// Will resources/_gen will get its own composite filesystem that
// also checks any theme.
IsResourceDir bool `json:"-"`
}
type Funcs ¶
type Funcs struct {
// OS env keys allowed to query in os.Getenv.
Getenv security.Whitelist `json:"getenv"`
}
Funcs holds template funcs policies.
type GoogleAnalytics ¶
type GoogleAnalytics struct {
// Enabling this will make the GA templates respect the
// "Do Not Track" HTTP header. See https://www.paulfurley.com/google-analytics-dnt/.
RespectDoNotTrack bool
// The GA tracking ID.
ID string
// contains filtered or unexported fields
}
GoogleAnalytics holds the privacy configuration settings related to the Google Analytics template.
type HTTP ¶
type HTTP struct {
// URLs to allow in remote HTTP (resources.Get, getJSON, getCSV).
URLs security.Whitelist `json:"urls"`
// HTTP methods to allow.
Methods security.Whitelist `json:"methods"`
// Media types where the Content-Type in the response is used instead of resolving from the file content.
MediaTypes security.Whitelist `json:"mediaTypes"`
}
type ImagingConfig ¶
type ImagingConfig struct {
// Default images quality setting (1-100). Only used for JPEG images.
Quality int
// Resample filter to use in resize operations.
ResampleFilter string
// Hint about what type of images this is.
// Currently only used when encoding to Webp.
// Default is "photo".
// Valid values are "picture", "photo", "drawing", "icon", or "text".
Hint string
// The anchor to use in Fill. Default is "smart", i.e. Smart Crop.
Anchor string
// Default color used in fill operations (e.g. "fff" for white).
BgColor string
Exif ExifConfig
}
ImagingConfig contains default images processing configuration. This will be fetched from site (or language) config.
type ImagingConfigInternal ¶
type ImagingConfigInternal struct {
BgColor color.Color
Hint webpoptions.EncodingPreset
ResampleFilter gift.Resampling
Anchor gift.Anchor
SourceHash string
Imaging ImagingConfig
}
func DecodeImagingConfig ¶
func DecodeImagingConfig(p config.Provider) (ImagingConfigInternal, error)
type Import ¶
type Import struct {
// Module path
Path string
// Ignore any config in config.toml (will still follow imports).
IgnoreConfig bool
// Do not follow any configured imports.
IgnoreImports bool
// Do not mount any folder in this import.
NoMounts bool
// Never vendor this import (only allowed in main project).
NoVendor bool
// Turn off this module.
Disable bool
// File mounts.
Mounts []Mount
// contains filtered or unexported fields
}
type Instagram ¶
type Instagram struct {
// If simple mode is enabled, a static and no-JS version of the Instagram
// image card will be built.
Simple bool
// The Simple variant of the Instagram is decorated with Bootstrap 4 card classes.
// This means that if you use Bootstrap 4 or want to provide your own CSS, you want
// to disable the inline CSS provided by Hugo.
DisableInlineCSS bool
// App or Client Access Token.
// If you are using a Client Access Token, remember that you must combine it with your App ID
// using a pipe symbol (<APPID>|<CLIENTTOKEN>) otherwise the request will fail.
AccessToken string
// contains filtered or unexported fields
}
Instagram holds the privacy configuration settings related to the Instagram shortcode.
type LanguageConfig ¶
type LanguageConfig struct {
// The language name, e.g. "English".
LanguageName string
// The language code, e.g. "en-US".
LanguageCode string
// The language title. When set, this will
// override site.Title for this language.
Title string
// The language direction, e.g. "ltr" or "rtl".
LanguageDirection string
// The language weight. When set to a non-zero value, this will
// be the main sort criteria for the language.
Weight int
// Set to true to disable this language.
Disabled bool
}
LanguageConfig holds the configuration for a single language. This is what is read from the config file.
func (LanguageConfig) Code ¶
func (l LanguageConfig) Code() string
func (LanguageConfig) Name ¶
func (l LanguageConfig) Name() string
type MediaTypeConfig ¶
type MediaTypeConfig struct {
// The file suffixes used for this media type.
Suffixes []string
// Delimiter used before suffix.
Delimiter string
Types media.Types
}
func DecodeMediaTypesConfig ¶
func DecodeMediaTypesConfig(p config.Provider) (MediaTypeConfig, error)
type MenuConfig ¶
type MinifyConfig ¶
type MinifyConfig struct {
// Whether to minify the published output (the HTML written to /public).
MinifyOutput bool
DisableHTML bool
DisableCSS bool
DisableJS bool
DisableJSON bool
DisableSVG bool
DisableXML bool
Tdewolff TdewolffConfig
}
func DecodeMinifyConfig ¶
func DecodeMinifyConfig(p config.Provider) (conf MinifyConfig, err error)
type ModuleConfig ¶
type ModuleConfig struct {
// File system mounts.
Mounts []Mount
// Module imports.
Imports []Import
}
func DecodeModuleConfig ¶
func DecodeModuleConfig(cfg config.Provider) (ModuleConfig, error)
DecodeModuleConfig creates a modules Config from a given Hugo configuration.
type Mount ¶
type Mount struct {
// Relative path in source repo, e.g. "scss".
Source string
// Relative target path, e.g. "assets/bootstrap/scss".
Target string
// Any file in this mount will be associated with this language.
Lang string
// Include only files matching the given Glob patterns (string or slice).
IncludeFiles any
// Exclude all files matching the given Glob patterns (string or slice).
ExcludeFiles any
}
func (Mount) ComponentAndName ¶
type OutputFormatConfig ¶
type OutputFormatConfig struct {
// The MediaType string. This must be a configured media type.
MediaType string
output.Format
}
OutputFormatConfig configures a single output format.
type OutputFormatsConfig ¶
type OutputFormatsConfig struct {
Configs map[string]OutputFormatConfig
output.Formats
}
type RSS ¶
type RSS struct {
// Limit the number of pages.
Limit int
}
RSS holds the functional configuration settings related to the RSS feeds.
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
// The named segments to render.
// This needs to match the name of the segment in the segments configuration.
RenderSegments []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 log IDs to ignore.
IgnoreLogs []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
// Whether to capitalize automatic page titles, applicable to section, taxonomy, and term pages.
CapitalizeListTitles 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
CommonDirs `mapstructure:",squash"`
}
RootConfig holds all the top-level configuration options in Hugo
func DecodeRoot ¶
func DecodeRoot(provider config.Provider) (RootConfig, error)
type SecurityConfig ¶
type SecurityConfig struct {
// Restricts access to os.Exec....
// <docsmeta>{ "newIn": "0.91.0" }</docsmeta>
hexec.Auth `json:"exec"`
// Restricts access to certain template funcs.
Funcs Funcs `json:"funcs"`
// Restricts access to resources.GetRemote, getJSON, getCSV.
HTTP HTTP `json:"http"`
// Allow inline shortcodes
EnableInlineShortcodes bool `json:"enableInlineShortcodes"`
}
func DecodeSecurityConfig ¶
func DecodeSecurityConfig(cfg config.Provider) (SecurityConfig, error)
type ServiceConfig ¶
type ServiceConfig struct {
Disqus Disqus
GoogleAnalytics GoogleAnalytics
Instagram Instagram
Twitter Twitter
Vimeo Vimeo
YouTube YouTube
RSS RSS
}
func DecodeServiceConfig ¶
func DecodeServiceConfig(cfg config.Provider) (c ServiceConfig, err error)
DecodeServiceConfig creates a services Config from a given Hugo configuration.
type SitemapConfig ¶
type SitemapConfig struct {
// The page change frequency.
ChangeFreq string
// The priority of the page.
Priority float64
// The sitemap filename.
Filename string
// Whether to disable page inclusion.
Disable bool
}
func DecodeSitemap ¶
func DecodeSitemap(prototype SitemapConfig, input map[string]any) (SitemapConfig, error)
type TdewolffConfig ¶
type Twitter ¶
type Twitter struct {
// When set to true, the Tweet and its embedded page on your site are not used
// for purposes that include personalized suggestions and personalized ads.
EnableDNT bool
// If simple mode is enabled, a static and no-JS version of the Tweet will be built.
Simple bool
// The Simple variant of Twitter is decorated with a basic set of inline styles.
// This means that if you want to provide your own CSS, you want
// to disable the inline CSS provided by Hugo.
DisableInlineCSS bool
// contains filtered or unexported fields
}
Twitter holds the privacy configuration settingsrelated to the Twitter shortcode.
type ViewName ¶
type Vimeo ¶
type Vimeo struct {
// When set to true, the Vimeo player will be blocked from tracking any session data,
// including all cookies and stats.
EnableDNT bool
// If simple mode is enabled, only a thumbnail is fetched from i.vimeocdn.com and
// shown with a play button overlaid. If a user clicks the button, he/she will
// be taken to the video page on vimeo.com in a new browser tab.
Simple bool
// contains filtered or unexported fields
}
Vimeo holds the privacy configuration settingsrelated to the Vimeo shortcode.
type YouTube ¶
type YouTube struct {
// When you turn on privacy-enhanced mode,
// YouTube won’t store information about visitors on your website
// unless the user plays the embedded video.
PrivacyEnhanced bool
// contains filtered or unexported fields
}
YouTube holds the privacy configuration settingsrelated to the YouTube shortcode.