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

package hugolib

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

Index

Package Files

alias.go author.go config.go gitinfo.go handler_base.go handler_file.go handler_meta.go handler_page.go hugo_info.go hugo_sites.go hugo_sites_build.go media.go menu.go multilingual.go page.go pageCache.go pageGroup.go pageSort.go page_collections.go page_output.go page_paths.go pagesPrevNext.go pagination.go permalinker.go permalinks.go scratch.go shortcode.go shortcodeparser.go site.go site_output.go site_render.go site_sections.go sitemap.go taxonomy.go translations.go

Constants

const (
    KindPage = "page"

    // The rest are node types; home page, sections etc.
    KindHome         = "home"
    KindSection      = "section"
    KindTaxonomy     = "taxonomy"
    KindTaxonomyTerm = "taxonomyTerm"
)

Variables

var (
    // CommitHash contains the current Git revision. Use make to build to make
    // sure this gets set.
    CommitHash string

    // BuildDate contains the date of the current build.
    BuildDate string
)
var ErrHasDraftAndPublished = errors.New("both draft and published parameters were found in page's frontmatter")

func HandlerMatch Uses

func HandlerMatch(h Handler, ext string) bool

func Handlers Uses

func Handlers() []Handler

func LoadConfig Uses

func LoadConfig(fs afero.Fs, relativeSourcePath, configFilename string) (*viper.Viper, error)

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

func RegisterHandler Uses

func RegisterHandler(h Handler)

type Author Uses

type Author struct {
    GivenName   string
    FamilyName  string
    DisplayName string
    Thumbnail   string
    Image       string
    ShortBio    string
    LongBio     string
    Email       string
    Social      AuthorSocial
}

Author contains details about the author of a page.

type AuthorList Uses

type AuthorList map[string]Author

AuthorList is a list of all authors and their metadata.

type AuthorSocial Uses

type AuthorSocial map[string]string

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

type BuildCfg Uses

type BuildCfg struct {
    // Whether we are in watch (server) mode
    Watching bool
    // Print build stats at the end of a build
    PrintStats bool
    // Reset site state before build. Use to force full rebuilds.
    ResetState bool
    // Re-creates the sites from configuration before a build.
    // This is needed if new languages are added.
    CreateSitesFromConfig bool
    // Skip rendering. Useful for testing.
    SkipRender bool
    // contains filtered or unexported fields
}

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

type Handle Uses

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

func (Handle) Extensions Uses

func (h Handle) Extensions() []string

type HandleResults Uses

type HandleResults chan<- HandledResult

type HandledResult Uses

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

func (HandledResult) Error Uses

func (h HandledResult) Error() string

HandledResult is an error

func (HandledResult) Page Uses

func (h HandledResult) Page() *Page

func (HandledResult) String Uses

func (h HandledResult) String() string

type Handler Uses

type Handler interface {
    FileConvert(*source.File, *Site) HandledResult
    PageConvert(*Page) HandledResult
    Read(*source.File, *Site) HandledResult
    Extensions() []string
}

func FindHandler Uses

func FindHandler(ext string) Handler

type HugoInfo Uses

type HugoInfo struct {
    Version    string
    Generator  template.HTML
    CommitHash string
    BuildDate  string
}

HugoInfo contains information about the current Hugo environment

type HugoSites Uses

type HugoSites struct {
    Sites []*Site

    *deps.Deps
    // 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) Pages Uses

func (h *HugoSites) Pages() Pages

Pages returns all pages for all sites.

type Image Uses

type Image struct {

    // The URL of the image. In some cases, the image URL may not be on the
    // same domain as your main site. This is fine, as long as both domains
    // are verified in Webmaster Tools. If, for example, you use a
    // content delivery network (CDN) to host your images, make sure that the
    // hosting site is verified in Webmaster Tools OR that you submit your
    // sitemap using robots.txt. In addition, make sure that your robots.txt
    // file doesn’t disallow the crawling of any content you want indexed.
    URL     string
    Title   string
    Caption string
    AltText string

    // The geographic location of the image. For example,
    // <image:geo_location>Limerick, Ireland</image:geo_location>.
    GeoLocation string

    // A URL to the license of the image.
    License string
}

An Image contains metadata for images + image sitemaps https://support.google.com/webmasters/answer/178636?hl=en

type Menu []*MenuEntry

Menu is a collection of menu entries.

func (m Menu) ByName() Menu

ByName sorts the menu by the name defined in the menu configuration.

func (m Menu) ByWeight() Menu

ByWeight sorts the menu by the weight defined in the menu configuration.

func (m Menu) Limit(n int) Menu

Limit limits the returned menu to n entries.

func (m Menu) Reverse() Menu

Reverse reverses the order of the menu entries.

func (m Menu) Sort() Menu

Sort sorts the menu by weight, name and then by identifier.

type MenuEntry struct {
    URL        string
    Name       string
    Menu       string
    Identifier string
    Pre        template.HTML
    Post       template.HTML
    Weight     int
    Parent     string
    Children   Menu
}

MenuEntry represents a menu item defined in either Page front matter or in the site config.

func (m *MenuEntry) HasChildren() bool

HasChildren returns whether this menu item has any children.

func (m *MenuEntry) IsEqual(inme *MenuEntry) bool

IsEqual returns whether the two menu entries represents the same menu entry.

func (m *MenuEntry) IsSameResource(inme *MenuEntry) bool

IsSameResource returns whether the two menu entries points to the same resource (URL).

func (m *MenuEntry) KeyName() string

KeyName returns the key used to identify this menu entry.

type Menus map[string]*Menu

Menus is a dictionary of menus.

type MetaHandle Uses

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

func NewMetaHandler Uses

func NewMetaHandler(in string) *MetaHandle

func (*MetaHandle) Convert Uses

func (mh *MetaHandle) Convert(i interface{}, s *Site, results HandleResults)

func (*MetaHandle) Handler Uses

func (mh *MetaHandle) Handler() Handler

func (*MetaHandle) Read Uses

func (mh *MetaHandle) Read(f *source.File, s *Site, results HandleResults)

type MetaHandler Uses

type MetaHandler interface {
    // Read the Files in and register
    Read(*source.File, *Site, HandleResults)

    // Generic Convert Function with coordination
    Convert(interface{}, *Site, HandleResults)

    Handle() Handler
}

type Multilingual Uses

type Multilingual struct {
    Languages helpers.Languages

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

func (*Multilingual) Language Uses

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

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
    WeightedPages WeightedPages
}

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

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() 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 OutputFormat Uses

type OutputFormat struct {
    // Rel constains a value that can be used to construct a rel link.
    // This is value is fetched from the output format definition.
    // Note that for pages with only one output format,
    // this method will always return "canonical".
    // As an example, the AMP output format will, by default, return "amphtml".
    //
    // See:
    // https://www.ampproject.org/docs/guides/deploy/discovery
    //
    // Most other output formats will have "alternate" as value for this.
    Rel string
    // contains filtered or unexported fields
}

And OutputFormat links to a representation of a resource.

func (OutputFormat) MediaType Uses

func (o OutputFormat) MediaType() media.Type

MediaType returns this OutputFormat's MediaType (MIME type).

func (OutputFormat) Name Uses

func (o OutputFormat) Name() string

Name returns this OutputFormat's name, i.e. HTML, AMP, JSON etc.

func (o *OutputFormat) Permalink() string

Permalink returns the absolute permalink to this output format.

func (o *OutputFormat) RelPermalink() string

Permalink returns the relative permalink to this output format.

type OutputFormats Uses

type OutputFormats []*OutputFormat

OutputFormats holds a list of the relevant output formats for a given resource.

func (OutputFormats) Get Uses

func (o OutputFormats) Get(name string) *OutputFormat

Get gets a OutputFormat given its name, i.e. json, html etc. It returns nil if not found.

type Page Uses

type Page struct {

    // Kind is the discriminator that identifies the different page types
    // in the different page collections. This can, as an example, be used
    // to to filter regular pages, find sections etc.
    // Kind will, for the pages available to the templates, be one of:
    // page, home, section, taxonomy and taxonomyTerm.
    // It is of string type to make it easy to reason about in
    // the templates.
    Kind string

    // Since Hugo 0.18 we got rid of the Node type. So now all pages are ...
    // pages (regular pages, home page, sections etc.).
    // Sections etc. will have child pages. These were earlier placed in .Data.Pages,
    // but can now be more intuitively also be fetched directly from .Pages.
    // This collection will be nil for regular pages.
    Pages Pages

    // Params contains configuration defined in the params section of page frontmatter.
    Params map[string]interface{}

    // Content sections
    Content         template.HTML
    Summary         template.HTML
    TableOfContents template.HTML

    Aliases []string

    Images []Image
    Videos []Video

    Truncated bool
    Draft     bool
    Status    string

    PublishDate time.Time
    ExpiryDate  time.Time

    // PageMeta contains page stats such as word count etc.
    PageMeta

    // Markup contains the markup type for the content.
    Markup string

    Layout string

    Source

    Position `json:"-"`

    GitInfo *gitmap.GitInfo

    Site *SiteInfo `json:"-"`

    Title       string
    Description string
    Keywords    []string
    Data        map[string]interface{}

    Date    time.Time
    Lastmod time.Time

    Sitemap Sitemap

    URLPath
    // contains filtered or unexported fields
}

func (*Page) AllTranslations Uses

func (p *Page) AllTranslations() Pages

AllTranslations returns all translations, including the current Page.

func (*Page) AlternativeOutputFormats Uses

func (p *Page) AlternativeOutputFormats() (OutputFormats, error)

AlternativeOutputFormats is only available on the top level rendering entry point, and not inside range loops on the Page collections. This method is just here to inform users of that restriction.

func (*Page) Author Uses

func (p *Page) Author() Author

func (*Page) Authors Uses

func (p *Page) Authors() AuthorList

func (*Page) Extension Uses

func (p *Page) Extension() string

func (*Page) FullFilePath Uses

func (p *Page) FullFilePath() string

func (*Page) FuzzyWordCount Uses

func (p *Page) FuzzyWordCount() int

func (*Page) GetParam Uses

func (p *Page) GetParam(key string) interface{}

func (*Page) HasMenuCurrent Uses

func (p *Page) HasMenuCurrent(menuID string, me *MenuEntry) bool

func (*Page) Hugo Uses

func (p *Page) Hugo() *HugoInfo

func (*Page) InSection Uses

func (p *Page) InSection(other interface{}) (bool, error)

InSection returns whether the given page is in the current section. Note that this will always return false for pages that are not either regular, home or section pages.

func (*Page) IsDraft Uses

func (p *Page) IsDraft() bool

func (*Page) IsExpired Uses

func (p *Page) IsExpired() bool

func (*Page) IsFuture Uses

func (p *Page) IsFuture() bool

func (*Page) IsHome Uses

func (p *Page) IsHome() bool

IsHome returns whether this is the home page.

func (*Page) IsMenuCurrent Uses

func (p *Page) IsMenuCurrent(menuID string, inme *MenuEntry) bool

func (*Page) IsNode Uses

func (p *Page) IsNode() bool

IsNode returns whether this is an item of one of the list types in Hugo, i.e. not a regular content page.

func (*Page) IsPage Uses

func (p *Page) IsPage() bool

IsPage returns whether this is a regular content page.

func (*Page) IsRenderable Uses

func (p *Page) IsRenderable() bool

func (*Page) IsSection Uses

func (p *Page) IsSection() bool

IsSection returns whether this is a section page.

func (*Page) IsTranslated Uses

func (p *Page) IsTranslated() bool

IsTranslated returns whether this content file is translated to other language(s).

func (*Page) Lang Uses

func (p *Page) Lang() string

func (*Page) Language Uses

func (p *Page) Language() *helpers.Language

func (*Page) LanguagePrefix Uses

func (p *Page) LanguagePrefix() string

func (*Page) LinkTitle Uses

func (p *Page) LinkTitle() string

func (*Page) Menus Uses

func (p *Page) Menus() PageMenus

func (*Page) Now Uses

func (p *Page) Now() time.Time

func (*Page) OutputFormats Uses

func (p *Page) OutputFormats() OutputFormats

OutputFormats gives the output formats for this Page.

func (*Page) Paginate Uses

func (p *Page) Paginate(seq interface{}, options ...interface{}) (*Pager, error)

Paginate invokes this Page's main output's Paginate method.

func (*Page) Paginator Uses

func (p *Page) Paginator(options ...interface{}) (*Pager, error)

Paginator get this Page's main output's paginator.

func (*Page) Param Uses

func (p *Page) Param(key interface{}) (interface{}, error)

Param is a convenience method to do lookups in Page's and Site's Params map, in that order.

This method is also implemented on Node and SiteInfo.

func (*Page) Parent Uses

func (p *Page) Parent() *Page

Parent returns a section's parent section or a page's section. To get a section's subsections, see Page's Sections method.

func (p *Page) Permalink() string

Permalink returns the absolute URL to this Page.

func (*Page) Plain Uses

func (p *Page) Plain() string

func (*Page) PlainWords Uses

func (p *Page) PlainWords() []string
func (p *Page) RSSLink() template.URL

func (*Page) RawContent Uses

func (p *Page) RawContent() string

func (*Page) ReadFrom Uses

func (p *Page) ReadFrom(buf io.Reader) (int64, error)

func (*Page) ReadingTime Uses

func (p *Page) ReadingTime() int

func (*Page) Ref Uses

func (p *Page) Ref(refs ...string) (string, error)
func (p *Page) RelPermalink() string

RelPermalink gets a URL to the resource relative to the host.

func (*Page) RelRef Uses

func (p *Page) RelRef(refs ...string) (string, error)

func (*Page) Render Uses

func (p *Page) Render(layout ...string) template.HTML

func (*Page) SafeSaveSourceAs Uses

func (p *Page) SafeSaveSourceAs(path string) error

func (*Page) SaveSource Uses

func (p *Page) SaveSource() error

func (*Page) SaveSourceAs Uses

func (p *Page) SaveSourceAs(path string) error

func (*Page) Scratch Uses

func (p *Page) Scratch() *Scratch

Scratch returns the writable context associated with this Page.

func (*Page) Section Uses

func (p *Page) Section() string

Section returns the first path element below the content root. Note that since Hugo 0.22 we support nested sections, but this will always be the first element of any nested path.

func (*Page) Sections Uses

func (p *Page) Sections() Pages

Sections returns this section's subsections, if any. Note that for non-sections, this method will always return an empty list.

func (*Page) SetSourceContent Uses

func (p *Page) SetSourceContent(content []byte)

func (*Page) SetSourceMetaData Uses

func (p *Page) SetSourceMetaData(in interface{}, mark rune) (err error)

func (*Page) String Uses

func (p *Page) String() string

func (*Page) TargetPath Uses

func (p *Page) TargetPath() (outfile string)

func (*Page) Translations Uses

func (p *Page) Translations() Pages

Translations returns the translations excluding the current Page.

func (*Page) Type Uses

func (p *Page) Type() string

func (*Page) URL Uses

func (p *Page) URL() string

func (*Page) UniqueID Uses

func (p *Page) UniqueID() string

func (*Page) WordCount Uses

func (p *Page) WordCount() int

type PageCollections Uses

type PageCollections struct {
    // Includes only pages of all types, and only pages in the current language.
    Pages Pages

    // Includes all pages in all languages, including the current one.
    // Includes pages of all types.
    AllPages Pages

    // A convenience cache for the regular pages.
    // This is for the current language only.
    RegularPages Pages

    // A convenience cache for the all the regular pages.
    AllRegularPages Pages
    // contains filtered or unexported fields
}

PageCollections contains the page collections for a site.

type PageGroup Uses

type PageGroup struct {
    Key   interface{}
    Pages Pages
}

PageGroup represents a group of pages, grouped by the key. The key is typically a year or similar.

type PageMenus map[string]*MenuEntry

PageMenus is a dictionary of menus defined in the Pages.

type PageMeta Uses

type PageMeta struct {
    Weight int
    // contains filtered or unexported fields
}

type PageOutput Uses

type PageOutput struct {
    *Page
    // contains filtered or unexported fields
}

PageOutput represents one of potentially many output formats of a given Page.

func (*PageOutput) AlternativeOutputFormats Uses

func (p *PageOutput) AlternativeOutputFormats() (OutputFormats, error)

OutputFormats gives the alternative output formats for this PageOutput. Note that we use the term "alternative" and not "alternate" here, as it does not necessarily replace the other format, it is an alternative representation.

func (*PageOutput) Paginate Uses

func (p *PageOutput) Paginate(seq interface{}, options ...interface{}) (*Pager, error)

Paginate gets this PageOutput's paginator if it's already created. If it's not, one will be created with the qiven sequence. Note that repeated calls will return the same result, even if the sequence is different.

func (*PageOutput) Paginator Uses

func (p *PageOutput) Paginator(options ...interface{}) (*Pager, error)

Paginator gets this PageOutput's paginator if it's already created. If it's not, one will be created with all pages in Data["Pages"].

func (*PageOutput) Render Uses

func (p *PageOutput) Render(layout ...string) template.HTML

type Pager Uses

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

Pager represents one of the elements in a paginator. The number, starting on 1, represents its place.

func (*Pager) First Uses

func (p *Pager) First() *Pager

First returns the pager for the first page.

func (*Pager) HasNext Uses

func (p *Pager) HasNext() bool

HasNext tests whether there are page(s) after the current.

func (*Pager) HasPrev Uses

func (p *Pager) HasPrev() bool

HasPrev tests whether there are page(s) before the current.

func (*Pager) Last Uses

func (p *Pager) Last() *Pager

Last returns the pager for the last page.

func (*Pager) Next Uses

func (p *Pager) Next() *Pager

Next returns the pager for the next page.

func (*Pager) NumberOfElements Uses

func (p *Pager) NumberOfElements() int

NumberOfElements gets the number of elements on this page.

func (*Pager) PageGroups Uses

func (p *Pager) PageGroups() PagesGroup

PageGroups return Page groups for this page. Note: If this return non-empty result, then Pages() will return empty.

func (*Pager) PageNumber Uses

func (p *Pager) PageNumber() int

PageNumber returns the current page's number in the pager sequence.

func (Pager) PageSize Uses

func (p Pager) PageSize() int

PageSize returns the size of each paginator page.

func (Pager) Pagers Uses

func (p Pager) Pagers() pagers

Pagers returns a list of pagers that can be used to build a pagination menu.

func (*Pager) Pages Uses

func (p *Pager) Pages() Pages

Pages returns the Pages on this page. Note: If this return a non-empty result, then PageGroups() will return empty.

func (*Pager) Prev Uses

func (p *Pager) Prev() *Pager

Prev returns the pager for the previous page.

func (Pager) String Uses

func (p Pager) String() string

func (Pager) TotalNumberOfElements Uses

func (p Pager) TotalNumberOfElements() int

TotalNumberOfElements returns the number of elements on all pages in this paginator.

func (Pager) TotalPages Uses

func (p Pager) TotalPages() int

TotalPages returns the number of pages in the paginator.

func (*Pager) URL Uses

func (p *Pager) URL() template.HTML

URL returns the URL to the current page.

type Pages Uses

type Pages []*Page

func (Pages) ByDate Uses

func (p Pages) ByDate() Pages

ByDate sorts the Pages by date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByExpiryDate Uses

func (p Pages) ByExpiryDate() Pages

ByExpiryDate sorts the Pages by publish date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLanguage Uses

func (p Pages) ByLanguage() Pages

ByLanguage sorts the Pages by the language's Weight.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLastmod Uses

func (p Pages) ByLastmod() Pages

ByLastmod sorts the Pages by the last modification date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLength Uses

func (p Pages) ByLength() Pages

ByLength sorts the Pages by length and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLinkTitle Uses

func (p Pages) ByLinkTitle() Pages

ByLinkTitle sorts the Pages by link title and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByParam Uses

func (p Pages) ByParam(paramsKey interface{}) Pages

func (Pages) ByPublishDate Uses

func (p Pages) ByPublishDate() Pages

ByPublishDate sorts the Pages by publish date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByTitle Uses

func (p Pages) ByTitle() Pages

ByTitle sorts the Pages by title and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByWeight Uses

func (p Pages) ByWeight() Pages

ByWeight sorts the Pages by weight and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) GroupBy Uses

func (p Pages) GroupBy(key string, order ...string) (PagesGroup, error)

GroupBy groups by the value in the given field or method name and with the given order. Valid values for order is asc, desc, rev and reverse.

func (Pages) GroupByDate Uses

func (p Pages) GroupByDate(format string, order ...string) (PagesGroup, error)

GroupByDate groups by the given page's Date value in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) GroupByExpiryDate Uses

func (p Pages) GroupByExpiryDate(format string, order ...string) (PagesGroup, error)

GroupByExpiryDate groups by the given page's ExpireDate value in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) GroupByParam Uses

func (p Pages) GroupByParam(key string, order ...string) (PagesGroup, error)

GroupByParam groups by the given page parameter key's value and with the given order. Valid values for order is asc, desc, rev and reverse.

func (Pages) GroupByParamDate Uses

func (p Pages) GroupByParamDate(key string, format string, order ...string) (PagesGroup, error)

GroupByParamDate groups by a date set as a param on the page in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) GroupByPublishDate Uses

func (p Pages) GroupByPublishDate(format string, order ...string) (PagesGroup, error)

GroupByPublishDate groups by the given page's PublishDate value in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) Len Uses

func (p Pages) Len() int

Len returns the number of pages in the list.

func (Pages) Limit Uses

func (p Pages) Limit(n int) Pages

Limit limits the number of pages returned to n.

func (Pages) Next Uses

func (p Pages) Next(cur *Page) *Page

Next returns the next page reletive to the given page.

func (Pages) Prev Uses

func (p Pages) Prev(cur *Page) *Page

Prev returns the previous page reletive to the given page.

func (Pages) Reverse Uses

func (p Pages) Reverse() Pages

Reverse reverses the order in Pages and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) Sort Uses

func (p Pages) Sort()

Sort sorts the pages by the default sort order defined: Order by Weight, Date, LinkTitle and then full file path.

func (Pages) String Uses

func (ps Pages) String() string

type PagesGroup Uses

type PagesGroup []PageGroup

PagesGroup represents a list of page groups. This is what you get when doing page grouping in the templates.

func (PagesGroup) Len Uses

func (psg PagesGroup) Len() int

Len returns the number of pages in the page group.

func (PagesGroup) Reverse Uses

func (p PagesGroup) Reverse() PagesGroup

Reverse reverses the order of this list of page groups.

type PermalinkOverrides Uses

type PermalinkOverrides map[string]pathPattern

PermalinkOverrides maps a section name to a PathPattern

type Permalinker Uses

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

Permalinker provides permalinks of both the relative and absolute kind.

type Position Uses

type Position struct {
    Prev          *Page
    Next          *Page
    PrevInSection *Page
    NextInSection *Page
}

type Scratch Uses

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

Scratch is a writable context used for stateful operations in Page/Node rendering.

func (*Scratch) Add Uses

func (c *Scratch) Add(key string, newAddend interface{}) (string, error)

Add will, for single values, add (using the + operator) the addend to the existing addend (if found). Supports numeric values and strings.

If the first add for a key is an array or slice, then the next value(s) will be appended.

func (*Scratch) Get Uses

func (c *Scratch) Get(key string) interface{}

Get returns a value previously set by Add or Set

func (*Scratch) GetSortedMapValues Uses

func (c *Scratch) GetSortedMapValues(key string) interface{}

GetSortedMapValues returns a sorted map previously filled with SetInMap

func (*Scratch) Set Uses

func (c *Scratch) Set(key string, value interface{}) string

Set stores a value with the given key in the Node context. This value can later be retrieved with Get.

func (*Scratch) SetInMap Uses

func (c *Scratch) SetInMap(key string, mapKey string, value interface{}) string

SetInMap stores a value to a map with the given key in the Node context. This map can later be retrieved with GetSortedMapValues.

type ShortcodeWithPage Uses

type ShortcodeWithPage struct {
    Params        interface{}
    Inner         template.HTML
    Page          *Page
    Parent        *ShortcodeWithPage
    IsNamedParams bool
    // 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) Ref Uses

func (scp *ShortcodeWithPage) Ref(ref string) (string, error)

Ref is a shortcut to the Ref method on Page.

func (*ShortcodeWithPage) RelRef Uses

func (scp *ShortcodeWithPage) RelRef(ref string) (string, error)

RelRef is a shortcut to the RelRef method on Page.

func (*ShortcodeWithPage) Scratch Uses

func (scp *ShortcodeWithPage) Scratch() *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() *SiteInfo

Site returns information about the current site.

type Site Uses

type Site struct {
    *PageCollections

    Files      []*source.File
    Taxonomies TaxonomyList

    Source   source.Input
    Sections Taxonomy
    Info     SiteInfo
    Menus    Menus

    Data     map[string]interface{}
    Language *helpers.Language

    // 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.

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.

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) Initialise Uses

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

func (*Site) NewPage Uses

func (s *Site) NewPage(name string) (*Page, error)

func (*Site) NewPageFrom Uses

func (s *Site) NewPageFrom(buf io.Reader, name string) (*Page, error)

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.

func (*Site) Stats Uses

func (s *Site) Stats()

Stats prints Hugo builds stats to the console. This is what you see after a successful hugo build.

type SiteInfo Uses

type SiteInfo struct {
    Taxonomies TaxonomyList
    Authors    AuthorList
    Social     SiteSocial
    *PageCollections
    Files           *[]*source.File
    Menus           *Menus
    Hugo            *HugoInfo
    Title           string
    RSSLink         string
    Author          map[string]interface{}
    LanguageCode    string
    DisqusShortname string
    GoogleAnalytics string
    Copyright       string
    LastChange      time.Time
    Permalinks      PermalinkOverrides
    Params          map[string]interface{}
    BuildDrafts     bool

    Data *map[string]interface{}

    Language       *helpers.Language
    LanguagePrefix string
    Languages      helpers.Languages
    // contains filtered or unexported fields
}

func (*SiteInfo) BaseURL Uses

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

func (*SiteInfo) GetPage Uses

func (s *SiteInfo) GetPage(typ string, path ...string) (*Page, error)

GetPage looks up a page of a given type in the path given.

{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }}

This will return nil when no page could be found, and will return the first page found if the key is ambigous.

func (*SiteInfo) Home Uses

func (s *SiteInfo) Home() (*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) IsMultiLingual Uses

func (s *SiteInfo) IsMultiLingual() bool

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) Ref Uses

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

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

func (*SiteInfo) RelRef Uses

func (s *SiteInfo) RelRef(ref string, 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() Taxonomy

Deprecated: Use .Site.Home.Sections. TODO(bep) Hugo 0.23 = Reuse as an alias for home's sections.

func (*SiteInfo) SitemapAbsURL Uses

func (s *SiteInfo) SitemapAbsURL() string

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

func (s *SiteInfo) SourceRelativeLink(ref string, currentPage *Page) (string, error)

SourceRelativeLink attempts to convert any source page relative links (like [../another.md]) into absolute links

func (*SiteInfo) SourceRelativeLinkFile Uses

func (s *SiteInfo) SourceRelativeLinkFile(ref string, currentPage *Page) (string, error)

SourceRelativeLinkFile attempts to convert any non-md source relative links (like [../another.gif]) into absolute links

func (*SiteInfo) String Uses

func (s *SiteInfo) String() 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 Sitemap Uses

type Sitemap struct {
    ChangeFreq string
    Priority   float64
    Filename   string
}

Sitemap configures the sitemap to be generated.

type Source Uses

type Source struct {
    Frontmatter []byte
    Content     []byte
    source.File
}

type Taxonomy Uses

type Taxonomy map[string]WeightedPages

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

TagTaxonomy['technology'] = WeightedPages
TagTaxonomy['go']  =  WeightedPages2

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) 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

type Translations Uses

type Translations map[string]*Page

Translations represent the other translations for a given page. The string here is the language code, as affected by the `post.LANG.md` filename.

type URLPath Uses

type URLPath struct {
    URL       string
    Permalink string
    Slug      string
    Section   string
}

type Video Uses

type Video struct {
    ThumbnailLoc         string
    Title                string
    Description          string
    ContentLoc           string
    PlayerLoc            string
    Duration             string
    ExpirationDate       string
    Rating               string
    ViewCount            string
    PublicationDate      string
    FamilyFriendly       string
    Restriction          string
    GalleryLoc           string
    Price                string
    RequiresSubscription string
    Uploader             string
    Live                 string
}

A Video contains metadata for videos + video sitemaps https://support.google.com/webmasters/answer/80471?hl=en

type WeightedPage Uses

type WeightedPage struct {
    Weight int
    *Page
}

A WeightedPage is a Page with a weight.

func (WeightedPage) String Uses

func (w WeightedPage) String() string

type WeightedPages Uses

type WeightedPages []WeightedPage

WeightedPages is a list of Pages with their corresponding (and relative) weight [{Weight: 30, Page: *1}, {Weight: 40, Page: *2}]

func (WeightedPages) Count Uses

func (wp WeightedPages) Count() int

Count returns the number of pages in this weighted page set.

func (WeightedPages) Len Uses

func (wp WeightedPages) Len() int

func (WeightedPages) Less Uses

func (wp WeightedPages) Less(i, j int) bool

func (WeightedPages) Next Uses

func (wp WeightedPages) Next(cur *Page) *Page

Next returns the next Page relative to the given Page in this weighted page set.

func (WeightedPages) Pages Uses

func (wp WeightedPages) Pages() Pages

Pages returns the Pages in this weighted page set.

func (WeightedPages) Prev Uses

func (wp WeightedPages) Prev(cur *Page) *Page

Prev returns the previous Page relative to the given Page in this weighted page set.

func (WeightedPages) Sort Uses

func (wp WeightedPages) Sort()

Sort stable sorts this weighted page set.

func (WeightedPages) Swap Uses

func (wp WeightedPages) Swap(i, j int)

Package hugolib imports 47 packages (graph) and is imported by 4 packages. Updated 2017-06-20. Refresh now. Tools for package owners.