hugo: github.com/gohugoio/hugo/hugolib Index | Files | Directories

package hugolib

import "github.com/gohugoio/hugo/hugolib"

Index

Package Files

alias.go collections.go config.go fileInfo.go gitinfo.go hugo_sites.go hugo_sites_build.go multilingual.go page.go page__common.go page__content.go page__data.go page__menus.go page__meta.go page__new.go page__output.go page__paginator.go page__paths.go page__per_output.go page__position.go page__ref.go page__tree.go page_kinds.go page_unwrap.go pagebundler.go pagebundler_capture.go pagebundler_handlers.go pagecollections.go permalinker.go prune_resources.go shortcode.go shortcode_page.go site.go site_output.go site_render.go site_sections.go taxonomy.go translations.go

Variables

var ErrNoConfigFile = errors.New("" /* 133 byte string literal not displayed */)

func IsContentFile Uses

func IsContentFile(filename string) bool

func LoadConfig Uses

func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (*viper.Viper, []string, error)

LoadConfig loads Hugo configuration into a new Viper and then adds a set of defaults.

func LoadConfigDefault Uses

func LoadConfigDefault(fs afero.Fs) (*viper.Viper, error)

LoadConfigDefault is a convenience method to load the default "config.toml" config.

type BuildCfg Uses

type BuildCfg struct {
    // Reset site state before build. Use to force full rebuilds.
    ResetState bool
    // If set, we re-create the sites from the given configuration before a build.
    // This is needed if new languages are added.
    NewConfig config.Provider
    // Skip rendering. Useful for testing.
    SkipRender bool

    // This is a partial re-render of some selected pages. This means
    // we should skip most of the processing.
    PartialReRender bool

    // Recently visited URLs. This is used for partial re-rendering.
    RecentlyVisited map[string]bool
    // contains filtered or unexported fields
}

BuildCfg holds build options used to, as an example, skip the render step.

type ConfigSourceDescriptor Uses

type ConfigSourceDescriptor struct {
    Fs  afero.Fs

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

    // The path to the directory to look for configuration. Is used if Filename is not
    // set or if it is set to a relative filename.
    Path string

    // The project's working dir. Is used to look for additional theme config.
    WorkingDir string

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

    // production, development
    Environment string
}

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

type HugoSites Uses

type HugoSites struct {
    Sites []*Site

    *deps.Deps

    // Keeps track of bundle directories and symlinks to enable partial rebuilding.
    ContentChanges *contentChangeMap
    // contains filtered or unexported fields
}

HugoSites represents the sites to build. Each site represents a language.

func NewHugoSites Uses

func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error)

NewHugoSites creates HugoSites from the given config.

func (*HugoSites) Build Uses

func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error

Build builds all sites. If filesystem events are provided, this is considered to be a potential partial rebuild.

func (*HugoSites) Data Uses

func (h *HugoSites) Data() map[string]interface{}

func (HugoSites) Done Uses

func (f HugoSites) Done() <-chan bool

func (HugoSites) FatalError Uses

func (f HugoSites) FatalError(err error)

FatalError error is used in some rare situations where it does not make sense to continue processing, to abort as soon as possible and log the error.

func (*HugoSites) GC Uses

func (h *HugoSites) GC() (int, error)

GC requires a build first and must run on it's own. It is not thread safe.

func (*HugoSites) GetContentPage Uses

func (h *HugoSites) GetContentPage(filename string) page.Page

GetContentPage finds a Page with content given the absolute filename. Returns nil if none found.

func (*HugoSites) IsMultihost Uses

func (h *HugoSites) IsMultihost() bool

func (*HugoSites) LanguageSet Uses

func (h *HugoSites) LanguageSet() map[string]bool

func (*HugoSites) NumLogErrors Uses

func (h *HugoSites) NumLogErrors() int

func (*HugoSites) Pages Uses

func (h *HugoSites) Pages() page.Pages

Pages returns all pages for all sites.

func (*HugoSites) PrintProcessingStats Uses

func (h *HugoSites) PrintProcessingStats(w io.Writer)

type Multilingual Uses

type Multilingual struct {
    Languages langs.Languages

    DefaultLang *langs.Language
    // contains filtered or unexported fields
}

Multilingual manages the all languages used in a multilingual site.

func (*Multilingual) Language Uses

func (ml *Multilingual) Language(lang string) *langs.Language

Language returns the Language associated with the given string.

type OrderedTaxonomy Uses

type OrderedTaxonomy []OrderedTaxonomyEntry

OrderedTaxonomy is another representation of an Taxonomy using an array rather than a map. Important because you can't order a map.

func (OrderedTaxonomy) Reverse Uses

func (t OrderedTaxonomy) Reverse() OrderedTaxonomy

Reverse reverses the order of the entries in this taxonomy.

type OrderedTaxonomyEntry Uses

type OrderedTaxonomyEntry struct {
    Name string
    page.WeightedPages
}

OrderedTaxonomyEntry is similar to an element of a Taxonomy, but with the key embedded (as name) e.g: {Name: Technology, page.WeightedPages: TaxonomyPages}

func (OrderedTaxonomyEntry) Count Uses

func (ie OrderedTaxonomyEntry) Count() int

Count returns the count the pages in this taxonomy.

func (OrderedTaxonomyEntry) Pages Uses

func (ie OrderedTaxonomyEntry) Pages() page.Pages

Pages returns the Pages for this taxonomy.

func (OrderedTaxonomyEntry) Term Uses

func (ie OrderedTaxonomyEntry) Term() string

Term returns the name given to this taxonomy.

type PageCollections Uses

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

PageCollections contains the page collections for a site.

func (*PageCollections) AllPages Uses

func (c *PageCollections) AllPages() page.Pages

AllPages returns all pages for all languages.

func (*PageCollections) AllRegularPages Uses

func (c *PageCollections) AllRegularPages() page.Pages

AllPages returns all regular pages for all languages.

func (*PageCollections) Pages Uses

func (c *PageCollections) Pages() page.Pages

Pages returns all pages. This is for the current language only.

func (*PageCollections) RegularPages Uses

func (c *PageCollections) RegularPages() page.Pages

RegularPages returns all the regular pages. This is for the current language only.

type Permalinker Uses

type Permalinker interface {
    Permalink() string
    RelPermalink() string
}

Permalinker provides permalinks of both the relative and absolute kind.

type ShortcodeWithPage Uses

type ShortcodeWithPage struct {
    Params        interface{}
    Inner         template.HTML
    Page          page.Page
    Parent        *ShortcodeWithPage
    Name          string
    IsNamedParams bool

    // Zero-based ordinal in relation to its parent. If the parent is the page itself,
    // this ordinal will represent the position of this shortcode in the page content.
    Ordinal int
    // contains filtered or unexported fields
}

ShortcodeWithPage is the "." context in a shortcode template.

func (*ShortcodeWithPage) Get Uses

func (scp *ShortcodeWithPage) Get(key interface{}) interface{}

Get is a convenience method to look up shortcode parameters by its key.

func (*ShortcodeWithPage) Position Uses

func (scp *ShortcodeWithPage) Position() text.Position

Position returns this shortcode's detailed position. Note that this information may be expensive to calculate, so only use this in error situations.

func (*ShortcodeWithPage) Ref Uses

func (scp *ShortcodeWithPage) Ref(args map[string]interface{}) (string, error)

Ref is a shortcut to the Ref method on Page. It passes itself as a context to get better error messages.

func (*ShortcodeWithPage) RelRef Uses

func (scp *ShortcodeWithPage) RelRef(args map[string]interface{}) (string, error)

RelRef is a shortcut to the RelRef method on Page. It passes itself as a context to get better error messages.

func (*ShortcodeWithPage) Scratch Uses

func (scp *ShortcodeWithPage) Scratch() *maps.Scratch

Scratch returns a scratch-pad scoped for this shortcode. This can be used as a temporary storage for variables, counters etc.

func (*ShortcodeWithPage) Site Uses

func (scp *ShortcodeWithPage) Site() page.Site

Site returns information about the current site.

type Site Uses

type Site struct {
    *PageCollections

    Taxonomies TaxonomyList

    Sections Taxonomy
    Info     SiteInfo

    // Logger etc.
    *deps.Deps `json:"-"`
    // contains filtered or unexported fields
}

Site contains all the information relevant for constructing a static site. The basic flow of information is as follows:

1. A list of Files is parsed and then converted into Pages.

2. Pages contain sections (based on the file they were generated from),

aliases and slugs (included in a pages frontmatter) which are the
various targets that will get generated.  There will be canonical
listing.  The canonical path can be overruled based on a pattern.

3. Taxonomies are created via configuration and will present some aspect of

the final page and typically a perm url.

4. All Pages are passed through a template based on their desired

layout based on numerous different elements.

5. The entire collection of files is written to disk.

func NewEnglishSite Uses

func NewEnglishSite(withTemplate ...func(templ tpl.TemplateHandler) error) (*Site, error)

NewEnglishSite creates a new site in English language. The site will have a template system loaded and ready to use. Note: This is mainly used in single site tests. TODO(bep) test refactor -- remove

func NewSite Uses

func NewSite(cfg deps.DepsCfg) (*Site, error)

NewSite creates a new site with the given dependency configuration. The site will have a template system loaded and ready to use. Note: This is mainly used in single site tests.

func NewSiteDefaultLang Uses

func NewSiteDefaultLang(withTemplate ...func(templ tpl.TemplateHandler) error) (*Site, error)

NewSiteDefaultLang creates a new site in the default language. The site will have a template system loaded and ready to use. Note: This is mainly used in single site tests. TODO(bep) test refactor -- remove

func NewSiteForCfg Uses

func NewSiteForCfg(cfg deps.DepsCfg) (*Site, error)

NewSiteForCfg creates a new site for the given configuration. The site will have a template system loaded and ready to use. Note: This is mainly used in single site tests.

func (*Site) GetRelatedDocsHandler Uses

func (s *Site) GetRelatedDocsHandler() *page.RelatedDocsHandler

func (*Site) Initialise Uses

func (s *Site) Initialise() (err error)

func (*Site) Language Uses

func (s *Site) Language() *langs.Language

func (*Site) Menus Uses

func (s *Site) Menus() navigation.Menus

func (*Site) RegisterMediaTypes Uses

func (s *Site) RegisterMediaTypes()

RegisterMediaTypes will register the Site's media types in the mime package, so it will behave correctly with Hugo's built-in server.

type SiteConfig Uses

type SiteConfig struct {
    // This contains all privacy related settings that can be used to
    // make the YouTube template etc. GDPR compliant.
    Privacy privacy.Config

    // Services contains config for services such as Google Analytics etc.
    Services services.Config
}

SiteConfig represents the config in .Site.Config.

type SiteInfo Uses

type SiteInfo struct {
    Authors page.AuthorList
    Social  SiteSocial

    RSSLink      string
    Author       map[string]interface{}
    LanguageCode string
    Copyright    string

    LanguagePrefix string
    Languages      langs.Languages

    BuildDrafts bool
    // contains filtered or unexported fields
}

func (*SiteInfo) AllPages Uses

func (s *SiteInfo) AllPages() page.Pages

func (*SiteInfo) AllRegularPages Uses

func (s *SiteInfo) AllRegularPages() page.Pages

func (*SiteInfo) BaseURL Uses

func (s *SiteInfo) BaseURL() template.URL

func (*SiteInfo) Config Uses

func (s *SiteInfo) Config() SiteConfig

func (*SiteInfo) Data Uses

func (s *SiteInfo) Data() map[string]interface{}

func (*SiteInfo) DisqusShortname Uses

func (s *SiteInfo) DisqusShortname() string

DisqusShortname is kept here for historic reasons.

func (*SiteInfo) GetPage Uses

func (s *SiteInfo) GetPage(ref ...string) (page.Page, error)

GetPage looks up a page of a given type for the given ref. In Hugo <= 0.44 you had to add Page Kind (section, home) etc. as the first argument and then either a unix styled path (with or without a leading slash)) or path elements separated. When we now remove the Kind from this API, we need to make the transition as painless as possible for existing sites. Most sites will use {{ .Site.GetPage "section" "my/section" }}, i.e. 2 arguments, so we test for that.

func (*SiteInfo) GoogleAnalytics Uses

func (s *SiteInfo) GoogleAnalytics() string

GoogleAnalytics is kept here for historic reasons.

func (*SiteInfo) Home Uses

func (s *SiteInfo) Home() (page.Page, error)

Home is a shortcut to the home page, equivalent to .Site.GetPage "home".

func (*SiteInfo) HomeAbsURL Uses

func (s *SiteInfo) HomeAbsURL() string

HomeAbsURL is a convenience method giving the absolute URL to the home page.

func (*SiteInfo) Hugo Uses

func (s *SiteInfo) Hugo() hugo.Info

func (*SiteInfo) IsMultiLingual Uses

func (s *SiteInfo) IsMultiLingual() bool

func (*SiteInfo) IsServer Uses

func (s *SiteInfo) IsServer() bool

func (*SiteInfo) Language Uses

func (s *SiteInfo) Language() *langs.Language

func (*SiteInfo) LastChange Uses

func (s *SiteInfo) LastChange() time.Time

func (*SiteInfo) Menus Uses

func (s *SiteInfo) Menus() navigation.Menus

func (*SiteInfo) Pages Uses

func (s *SiteInfo) Pages() page.Pages

func (*SiteInfo) Param Uses

func (s *SiteInfo) Param(key interface{}) (interface{}, error)

Param is a convenience method to do lookups in SiteInfo's Params map.

This method is also implemented on Page and Node.

func (*SiteInfo) Params Uses

func (s *SiteInfo) Params() map[string]interface{}
func (s *SiteInfo) Permalinks() map[string]string

func (*SiteInfo) Ref Uses

func (s *SiteInfo) Ref(ref string, page page.Page, options ...string) (string, error)

Ref will give an absolute URL to ref in the given Page.

func (*SiteInfo) RegularPages Uses

func (s *SiteInfo) RegularPages() page.Pages

func (*SiteInfo) RelRef Uses

func (s *SiteInfo) RelRef(ref string, page page.Page, options ...string) (string, error)

RelRef will give an relative URL to ref in the given Page.

func (*SiteInfo) Sections Uses

func (s *SiteInfo) Sections() page.Pages

Sections returns the top level sections.

func (*SiteInfo) ServerPort Uses

func (s *SiteInfo) ServerPort() int

ServerPort returns the port part of the BaseURL, 0 if none found.

func (*SiteInfo) Site Uses

func (s *SiteInfo) Site() page.Site

func (*SiteInfo) SitemapAbsURL Uses

func (s *SiteInfo) SitemapAbsURL() string

SitemapAbsURL is a convenience method giving the absolute URL to the sitemap.

func (*SiteInfo) Sites Uses

func (s *SiteInfo) Sites() page.Sites

Sites is a convenience method to get all the Hugo sites/languages configured.

func (*SiteInfo) String Uses

func (s *SiteInfo) String() string

func (*SiteInfo) Taxonomies Uses

func (s *SiteInfo) Taxonomies() interface{}

TODO(bep) type

func (*SiteInfo) Title Uses

func (s *SiteInfo) Title() string

type SiteSocial Uses

type SiteSocial map[string]string

SiteSocial is a place to put social details on a site level. These are the standard keys that themes will expect to have available, but can be expanded to any others on a per site basis github facebook facebook_admin twitter twitter_domain googleplus pinterest instagram youtube linkedin

type Taxonomy Uses

type Taxonomy map[string]page.WeightedPages

A Taxonomy is a map of keywords to a list of pages. For example

TagTaxonomy['technology'] = page.WeightedPages
TagTaxonomy['go']  =  page.WeightedPages

func (Taxonomy) Alphabetical Uses

func (i Taxonomy) Alphabetical() OrderedTaxonomy

Alphabetical returns an ordered taxonomy sorted by key name.

func (Taxonomy) ByCount Uses

func (i Taxonomy) ByCount() OrderedTaxonomy

ByCount returns an ordered taxonomy sorted by # of pages per key. If taxonomies have the same # of pages, sort them alphabetical

func (Taxonomy) Count Uses

func (i Taxonomy) Count(key string) int

Count the weighted pages for the given key.

func (Taxonomy) Get Uses

func (i Taxonomy) Get(key string) page.WeightedPages

Get the weighted pages for the given key.

func (Taxonomy) TaxonomyArray Uses

func (i Taxonomy) TaxonomyArray() OrderedTaxonomy

TaxonomyArray returns an ordered taxonomy with a non defined order.

type TaxonomyList Uses

type TaxonomyList map[string]Taxonomy

The TaxonomyList is a list of all taxonomies and their values e.g. List['tags'] => TagTaxonomy (from above)

func (TaxonomyList) String Uses

func (tl TaxonomyList) String() string

Directories

PathSynopsis
filesystemsPackage filesystems provides the fine grained file systems used by Hugo.
paths

Package hugolib imports 69 packages (graph) and is imported by 44 packages. Updated 2019-05-18. Refresh now. Tools for package owners.