Version: v0.88.1 Latest Latest

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

Go to latest
Published: Sep 4, 2021 License: Apache-2.0 Imports: 20 Imported by: 335




This section is empty.


View Source
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,
		"taxonomies":    true,

	// ConfigRootKeys is a sorted version of ConfigRootKeysSet.
	ConfigRootKeys []string
View Source
var DefaultBuild = Build{
	UseResourceCacheWhen: "fallback",
	WriteStats:           false,
View Source
var (
	ValidConfigFileExtensions = []string{"toml", "yaml", "yml", "json"}


func FromFileToMap added in v0.54.0

func FromFileToMap(fs afero.Fs, filename string) (map[string]interface{}, error)

FromFileToMap is the same as FromFile, but it returns the config values as a simple map.

func GetNumWorkerMultiplier added in v0.55.0

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 added in v0.42.1

func GetStringSlicePreserveString(cfg Provider, key string) []string

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 added in v0.54.0

func IsValidConfigFilename(filename string) bool

IsValidConfigFilename returns whether filename is one of the supported config formats in Hugo.

func RenameKeys added in v0.54.0

func RenameKeys(m map[string]interface{})

RenameKeys renames config keys in m recursively according to a global Hugo alias definition.

func SetBaseTestDefaults added in v0.55.0

func SetBaseTestDefaults(cfg Provider)

SetBaseTestDefaults provides some common config defaults used in tests.

func SetEnvVars added in v0.56.0

func SetEnvVars(oldVars *[]string, keyValues ...string)

SetEnvVars sets vars on the form key=value in the oldVars slice.

func SplitEnvVar added in v0.56.0

func SplitEnvVar(v string) (string, string)


type Build added in v0.66.0

type Build 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).
	WriteStats bool

	// Can be used to toggle off writing of the intellinsense /assets/jsconfig.js
	// file.
	NoJSConfigInAssets bool

Build holds some build related configuration.

func DecodeBuild added in v0.66.0

func DecodeBuild(cfg Provider) Build

func (Build) UseResourceCache added in v0.66.0

func (b Build) UseResourceCache(err error) bool

type Headers added in v0.67.0

type Headers struct {
	For    string
	Values map[string]interface{}

type KeyParams added in v0.84.0

type KeyParams struct {
	Key    string
	Params maps.Params

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]interface{}
	GetStringMapString(key string) map[string]string
	GetStringSlice(key string) []string
	Get(key string) interface{}
	Set(key string, value interface{})
	Merge(key string, value interface{})
	SetDefaults(params maps.Params)
	WalkParams(walkFn func(params ...KeyParams) bool)
	IsSet(key string) bool

Provider provides the configuration settings for Hugo.

func FromConfigString added in v0.42.1

func FromConfigString(config, configType string) (Provider, error)

FromConfigString creates a config from the given YAML, JSON or TOML config. This is useful in tests.

func FromFile added in v0.54.0

func FromFile(fs afero.Fs, filename string) (Provider, error)

FromFile loads the configuration from the given filename.

func LoadConfigFromDir added in v0.84.0

func LoadConfigFromDir(sourceFs afero.Fs, configDir, environment string) (Provider, []string, error)

func New added in v0.84.0

func New() Provider

New creates a Provider backed by an empty maps.Params.

func NewCompositeConfig added in v0.84.0

func NewCompositeConfig(base, layer Provider) Provider

NewCompositeConfig creates a new composite Provider with a read-only base and a writeable layer.

func NewFrom added in v0.84.0

func NewFrom(params maps.Params) Provider

NewFrom creates a Provider backed by params.

type Redirect added in v0.72.0

type Redirect struct {
	From   string
	To     string
	Status int
	Force  bool

func (Redirect) IsZero added in v0.72.0

func (r Redirect) IsZero() bool

type Server added in v0.67.0

type Server struct {
	Headers   []Headers
	Redirects []Redirect
	// contains filtered or unexported fields

Config for the dev server.

func DecodeServer added in v0.67.0

func DecodeServer(cfg Provider) (*Server, error)

func (*Server) MatchHeaders added in v0.72.0

func (s *Server) MatchHeaders(pattern string) []types.KeyValueStr

func (*Server) MatchRedirect added in v0.72.0

func (s *Server) MatchRedirect(pattern string) Redirect

type Sitemap added in v0.55.0

type Sitemap struct {
	ChangeFreq string
	Priority   float64
	Filename   string

Sitemap configures the sitemap to be generated.

func DecodeSitemap added in v0.55.0

func DecodeSitemap(prototype Sitemap, input map[string]interface{}) Sitemap


Path Synopsis

Jump to

Keyboard shortcuts

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