package hugolib
import "github.com/gohugoio/hugo/hugolib"
Index ¶
- Constants
- Variables
- func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (*viper.Viper, []string, error)
- func LoadConfigDefault(fs afero.Fs) (*viper.Viper, error)
- type Author
- type AuthorList
- type AuthorSocial
- type BuildCfg
- type ConfigSourceDescriptor
- type HugoInfo
- type HugoSites
- func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error)
- func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error
- func (h *HugoSites) GC() (int, error)
- func (h *HugoSites) GetContentPage(filename string) *Page
- func (h *HugoSites) IsMultihost() bool
- func (h *HugoSites) Pages() Pages
- func (h *HugoSites) PrintProcessingStats(w io.Writer)
- type Image
- type Menu
- func (m Menu) ByName() Menu
- func (m Menu) ByWeight() Menu
- func (m Menu) Limit(n int) Menu
- func (m Menu) Reverse() Menu
- func (m Menu) Sort() Menu
- type MenuEntry
- func (m *MenuEntry) HasChildren() bool
- func (m *MenuEntry) IsEqual(inme *MenuEntry) bool
- func (m *MenuEntry) IsSameResource(inme *MenuEntry) bool
- func (m *MenuEntry) KeyName() string
- func (m *MenuEntry) Title() string
- type Menus
- type Multilingual
- type OrderedTaxonomy
- type OrderedTaxonomyEntry
- func (ie OrderedTaxonomyEntry) Count() int
- func (ie OrderedTaxonomyEntry) Pages() Pages
- func (ie OrderedTaxonomyEntry) Term() string
- type OutputFormat
- func (o OutputFormat) MediaType() media.Type
- func (o OutputFormat) Name() string
- func (o *OutputFormat) Permalink() string
- func (o *OutputFormat) RelPermalink() string
- type OutputFormats
- type Page
- func (p *Page) AllTranslations() Pages
- func (p *Page) AlternativeOutputFormats() (OutputFormats, error)
- func (p *Page) Author() Author
- func (p *Page) Authors() AuthorList
- func (p *Page) CurrentSection() *Page
- func (p *Page) Eq(other interface{}) bool
- func (p *Page) FullFilePath() string
- func (p *Page) FuzzyWordCount() int
- func (p *Page) GetParam(key string) interface{}
- func (p *Page) HasMenuCurrent(menuID string, me *MenuEntry) bool
- func (p *Page) HasShortcode(name string) bool
- func (p *Page) Hugo() *HugoInfo
- func (p *Page) InSection(other interface{}) (bool, error)
- func (p *Page) IsAncestor(other interface{}) (bool, error)
- func (p *Page) IsDescendant(other interface{}) (bool, error)
- func (p *Page) IsDraft() bool
- func (p *Page) IsExpired() bool
- func (p *Page) IsFuture() bool
- func (p *Page) IsHome() bool
- func (p *Page) IsMenuCurrent(menuID string, inme *MenuEntry) bool
- func (p *Page) IsNode() bool
- func (p *Page) IsPage() bool
- func (p *Page) IsRenderable() bool
- func (p *Page) IsSection() bool
- func (p *Page) IsTranslated() bool
- func (p *Page) Lang() string
- func (p *Page) Language() *helpers.Language
- func (p *Page) LanguagePrefix() string
- func (p *Page) LinkTitle() string
- func (p *Page) Menus() PageMenus
- func (p *Page) Name() string
- func (p *Page) OutputFormats() OutputFormats
- func (p *Page) Paginate(seq interface{}, options ...interface{}) (*Pager, error)
- func (p *Page) Paginator(options ...interface{}) (*Pager, error)
- func (p *Page) Param(key interface{}) (interface{}, error)
- func (p *Page) Params() map[string]interface{}
- func (p *Page) Parent() *Page
- func (p *Page) Permalink() string
- func (p *Page) Plain() string
- func (p *Page) PlainWords() []string
- func (p *Page) PubDate() time.Time
- func (p *Page) RSSLink() template.URL
- func (p *Page) RawContent() string
- func (p *Page) ReadFrom(buf io.Reader) (int64, error)
- func (p *Page) ReadingTime() int
- func (p *Page) Ref(refs ...string) (string, error)
- func (p *Page) RelPermalink() string
- func (p *Page) RelRef(refs ...string) (string, error)
- func (p *Page) Render(layout ...string) template.HTML
- func (*Page) ResourceType() string
- func (p *Page) SafeSaveSourceAs(path string) error
- func (p *Page) SaveSource() error
- func (p *Page) SaveSourceAs(path string) error
- func (p *Page) Scratch() *Scratch
- func (p *Page) SearchKeywords(cfg related.IndexConfig) ([]related.Keyword, error)
- func (p *Page) Section() string
- func (p *Page) Sections() Pages
- func (p *Page) SetSourceContent(content []byte)
- func (p *Page) SetSourceMetaData(in interface{}, mark rune) (err error)
- func (p *Page) Sites() SiteInfos
- func (p *Page) String() string
- func (p *Page) Title() string
- func (p *Page) TranslationKey() string
- func (p *Page) Translations() Pages
- func (p *Page) Type() string
- func (p *Page) URL() string
- func (p *Page) UniqueID() string
- func (p *Page) WordCount() int
- type PageCollections
- type PageGenealogist
- type PageGroup
- type PageMenus
- type PageMeta
- type PageOutput
- func (p *PageOutput) AlternativeOutputFormats() (OutputFormats, error)
- func (p *PageOutput) Paginate(seq interface{}, options ...interface{}) (*Pager, error)
- func (p *PageOutput) Paginator(options ...interface{}) (*Pager, error)
- func (p *PageOutput) Render(layout ...string) template.HTML
- func (p *PageOutput) Resources() resource.Resources
- type Pager
- func (p *Pager) First() *Pager
- func (p *Pager) HasNext() bool
- func (p *Pager) HasPrev() bool
- func (p *Pager) Last() *Pager
- func (p *Pager) Next() *Pager
- func (p *Pager) NumberOfElements() int
- func (p *Pager) PageGroups() PagesGroup
- func (p *Pager) PageNumber() int
- func (p Pager) PageSize() int
- func (p Pager) Pagers() pagers
- func (p *Pager) Pages() Pages
- func (p *Pager) Prev() *Pager
- func (p Pager) String() string
- func (p Pager) TotalNumberOfElements() int
- func (p Pager) TotalPages() int
- func (p *Pager) URL() template.HTML
- type Pages
- func (p Pages) ByDate() Pages
- func (p Pages) ByExpiryDate() Pages
- func (p Pages) ByLanguage() Pages
- func (p Pages) ByLastmod() Pages
- func (p Pages) ByLength() Pages
- func (p Pages) ByLinkTitle() Pages
- func (p Pages) ByParam(paramsKey interface{}) Pages
- func (p Pages) ByPublishDate() Pages
- func (p Pages) ByTitle() Pages
- func (p Pages) ByWeight() Pages
- func (p Pages) GroupBy(key string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByDate(format string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByExpiryDate(format string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByParam(key string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByParamDate(key string, format string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByPublishDate(format string, order ...string) (PagesGroup, error)
- func (p Pages) Len() int
- func (p Pages) Limit(n int) Pages
- func (p1 Pages) MergeByLanguage(p2 Pages) Pages
- func (p1 Pages) MergeByLanguageInterface(in interface{}) (interface{}, error)
- func (p Pages) Next(cur *Page) *Page
- func (p Pages) Prev(cur *Page) *Page
- func (p Pages) Related(doc related.Document) (Pages, error)
- func (p Pages) RelatedIndices(doc related.Document, indices ...interface{}) (Pages, error)
- func (p Pages) RelatedTo(args ...types.KeyValues) (Pages, error)
- func (p Pages) Reverse() Pages
- func (p Pages) Sort()
- func (ps Pages) String() string
- type PagesGroup
- type PermalinkOverrides
- type Permalinker
- type Position
- type Scratch
- func (c *Scratch) Add(key string, newAddend interface{}) (string, error)
- func (c *Scratch) Delete(key string) string
- func (c *Scratch) Get(key string) interface{}
- func (c *Scratch) GetSortedMapValues(key string) interface{}
- func (c *Scratch) Set(key string, value interface{}) string
- func (c *Scratch) SetInMap(key string, mapKey string, value interface{}) string
- type ShortcodeWithPage
- func (scp *ShortcodeWithPage) Get(key interface{}) interface{}
- func (scp *ShortcodeWithPage) Ref(ref string) (string, error)
- func (scp *ShortcodeWithPage) RelRef(ref string) (string, error)
- func (scp *ShortcodeWithPage) Scratch() *Scratch
- func (scp *ShortcodeWithPage) Site() *SiteInfo
- type Site
- func NewEnglishSite(withTemplate ...func(templ tpl.TemplateHandler) error) (*Site, error)
- func NewSite(cfg deps.DepsCfg) (*Site, error)
- func NewSiteDefaultLang(withTemplate ...func(templ tpl.TemplateHandler) error) (*Site, error)
- func NewSiteForCfg(cfg deps.DepsCfg) (*Site, error)
- func (s *Site) Initialise() (err error)
- func (s *Site) NewPage(name string) (*Page, error)
- func (s *Site) NewPageFrom(buf io.Reader, name string) (*Page, error)
- func (s *Site) RegisterMediaTypes()
- type SiteInfo
- func (s *SiteInfo) BaseURL() template.URL
- func (s *SiteInfo) GetPage(typ string, path ...string) (*Page, error)
- func (s *SiteInfo) Home() (*Page, error)
- func (s *SiteInfo) HomeAbsURL() string
- func (s *SiteInfo) IsMultiLingual() bool
- func (s *SiteInfo) IsServer() bool
- func (s *SiteInfo) Param(key interface{}) (interface{}, error)
- func (s *SiteInfo) Ref(ref string, page *Page, options ...string) (string, error)
- func (s *SiteInfo) RelRef(ref string, page *Page, options ...string) (string, error)
- func (s *SiteInfo) Sections() Pages
- func (s *SiteInfo) ServerPort() int
- func (s *SiteInfo) SitemapAbsURL() string
- func (s *SiteInfo) String() string
- type SiteInfos
- type SiteSocial
- type Sitemap
- type Source
- type Taxonomy
- func (i Taxonomy) Alphabetical() OrderedTaxonomy
- func (i Taxonomy) ByCount() OrderedTaxonomy
- func (i Taxonomy) Count(key string) int
- func (i Taxonomy) Get(key string) WeightedPages
- func (i Taxonomy) TaxonomyArray() OrderedTaxonomy
- type TaxonomyList
- type Translations
- type Video
- type WeightedPage
- type WeightedPages
- func (wp WeightedPages) Count() int
- func (wp WeightedPages) Len() int
- func (wp WeightedPages) Less(i, j int) bool
- func (wp WeightedPages) Next(cur *Page) *Page
- func (wp WeightedPages) Pages() Pages
- func (wp WeightedPages) Prev(cur *Page) *Page
- func (wp WeightedPages) Sort()
- func (wp WeightedPages) Swap(i, j int)
Constants ¶
const ( KindPage = "page" 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")
Functions ¶
func LoadConfig ¶
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 ¶
LoadConfigDefault is a convenience method to load the default "config.toml" config.
Types ¶
type Author ¶
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 ¶
AuthorList is a list of all authors and their metadata.
type AuthorSocial ¶
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 ¶
type BuildCfg struct { // 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 // 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 ¶
type ConfigSourceDescriptor struct { Fs afero.Fs // Full path to the config file to use, i.e. /my/project/config.toml Filename string // The path to the directory to look for configuration. Is used if Filename is not // set. Path string // The project's working dir. Is used to look for additional theme config. WorkingDir string }
ConfigSourceDescriptor describes where to find the config (e.g. config.toml etc.).
type HugoInfo ¶
type HugoInfo struct { Version helpers.HugoVersionString Generator template.HTML CommitHash string BuildDate string }
HugoInfo contains information about the current Hugo environment
type HugoSites ¶
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 ¶
NewHugoSites creates HugoSites from the given config.
func (*HugoSites) Build ¶
Build builds all sites. If filesystem events are provided, this is considered to be a potential partial rebuild.
func (*HugoSites) GC ¶
GC requires a build first.
func (*HugoSites) GetContentPage ¶
GetContentPage finds a Page with content given the absolute filename. Returns nil if none found.
func (*HugoSites) IsMultihost ¶
func (*HugoSites) Pages ¶
Pages returns all pages for all sites.
func (*HugoSites) PrintProcessingStats ¶
type Image ¶
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 ¶
type Menu []*MenuEntry
Menu is a collection of menu entries.
func (Menu) ByName ¶
ByName sorts the menu by the name defined in the menu configuration.
func (Menu) ByWeight ¶
ByWeight sorts the menu by the weight defined in the menu configuration.
func (Menu) Limit ¶
Limit limits the returned menu to n entries.
func (Menu) Reverse ¶
Reverse reverses the order of the menu entries.
func (Menu) Sort ¶
Sort sorts the menu by weight, name and then by identifier.
type MenuEntry ¶
type MenuEntry struct { URL string Page *Page Name string Menu string Identifier string Pre template.HTML Post template.HTML Weight int Parent string Children Menu // contains filtered or unexported fields }
MenuEntry represents a menu item defined in either Page front matter or in the site config.
func (*MenuEntry) HasChildren ¶
HasChildren returns whether this menu item has any children.
func (*MenuEntry) IsEqual ¶
IsEqual returns whether the two menu entries represents the same menu entry.
func (*MenuEntry) IsSameResource ¶
IsSameResource returns whether the two menu entries points to the same resource (URL).
func (*MenuEntry) KeyName ¶
KeyName returns the key used to identify this menu entry.
func (*MenuEntry) Title ¶
type Menus ¶
Menus is a dictionary of menus.
type Multilingual ¶
type Multilingual struct { Languages helpers.Languages DefaultLang *helpers.Language // contains filtered or unexported fields }
Multilingual manages the all languages used in a multilingual site.
func (*Multilingual) Language ¶
func (ml *Multilingual) Language(lang string) *helpers.Language
Language returns the Language associated with the given string.
type OrderedTaxonomy ¶
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 ¶
func (t OrderedTaxonomy) Reverse() OrderedTaxonomy
Reverse reverses the order of the entries in this taxonomy.
type OrderedTaxonomyEntry ¶
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 ¶
func (ie OrderedTaxonomyEntry) Count() int
Count returns the count the pages in this taxonomy.
func (OrderedTaxonomyEntry) Pages ¶
func (ie OrderedTaxonomyEntry) Pages() Pages
Pages returns the Pages for this taxonomy.
func (OrderedTaxonomyEntry) Term ¶
func (ie OrderedTaxonomyEntry) Term() string
Term returns the name given to this taxonomy.
type OutputFormat ¶
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 }
OutputFormat links to a representation of a resource.
func (OutputFormat) MediaType ¶
func (o OutputFormat) MediaType() media.Type
MediaType returns this OutputFormat's MediaType (MIME type).
func (OutputFormat) Name ¶
func (o OutputFormat) Name() string
Name returns this OutputFormat's name, i.e. HTML, AMP, JSON etc.
func (*OutputFormat) Permalink ¶
func (o *OutputFormat) Permalink() string
Permalink returns the absolute permalink to this output format.
func (*OutputFormat) RelPermalink ¶
func (o *OutputFormat) RelPermalink() string
RelPermalink returns the relative permalink to this output format.
type OutputFormats ¶
type OutputFormats []*OutputFormat
OutputFormats holds a list of the relevant output formats for a given resource.
func (OutputFormats) Get ¶
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 ¶
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 // Since Hugo 0.32, a Page can have resources such as images and CSS associated // with itself. The resource will typically be placed relative to the Page, // but templates should use the links (Permalink and RelPermalink) // provided by the Resource object. Resources resource.Resources // Content sections Content template.HTML Summary template.HTML TableOfContents template.HTML Aliases []string Images []Image Videos []Video Truncated bool Draft bool Status string // 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:"-"` Description string Keywords []string Data map[string]interface{} pagemeta.PageDates Sitemap Sitemap pagemeta.URLPath // contains filtered or unexported fields }
func (*Page) AllTranslations ¶
AllTranslations returns all translations, including the current Page.
func (*Page) AlternativeOutputFormats ¶
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 ¶
func (*Page) Authors ¶
func (p *Page) Authors() AuthorList
func (*Page) CurrentSection ¶
CurrentSection returns the page's current section or the page itself if home or a section. Note that this will return nil for pages that is not regular, home or section pages.
func (*Page) Eq ¶
Eq returns whether the current page equals the given page. Note that this is more accurate than doing `{{ if eq $page $otherPage }}` since a Page can be embedded in another type.
func (*Page) FullFilePath ¶
func (*Page) FuzzyWordCount ¶
func (*Page) GetParam ¶
func (*Page) HasMenuCurrent ¶
func (*Page) HasShortcode ¶
HasShortcode return whether the page has a shortcode with the given name. This method is mainly motivated with the Hugo Docs site's need for a list of pages with the `todo` shortcode in it.
func (*Page) Hugo ¶
func (*Page) InSection ¶
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) IsAncestor ¶
IsAncestor returns whether the current page is an ancestor of the given page. Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
func (*Page) IsDescendant ¶
IsDescendant returns whether the current page is a descendant of the given page. Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
func (*Page) IsDraft ¶
func (*Page) IsExpired ¶
func (*Page) IsFuture ¶
func (*Page) IsHome ¶
IsHome returns whether this is the home page.
func (*Page) IsMenuCurrent ¶
func (*Page) IsNode ¶
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 ¶
IsPage returns whether this is a regular content page.
func (*Page) IsRenderable ¶
func (*Page) IsSection ¶
IsSection returns whether this is a section page.
func (*Page) IsTranslated ¶
IsTranslated returns whether this content file is translated to other language(s).
func (*Page) Lang ¶
func (*Page) Language ¶
func (*Page) LanguagePrefix ¶
func (*Page) LinkTitle ¶
func (*Page) Menus ¶
func (*Page) Name ¶
See resource.Resource This value is used, by default, in Resources.ByPrefix etc.
func (*Page) OutputFormats ¶
func (p *Page) OutputFormats() OutputFormats
OutputFormats gives the output formats for this Page.
func (*Page) Paginate ¶
Paginate invokes this Page's main output's Paginate method.
func (*Page) Paginator ¶
Paginator get this Page's main output's paginator.
func (*Page) Param ¶
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) Params ¶
func (*Page) Parent ¶
Parent returns a section's parent section or a page's section. To get a section's subsections, see Page's Sections method.
func (*Page) Permalink ¶
Permalink returns the absolute URL to this Page.
func (*Page) Plain ¶
func (*Page) PlainWords ¶
func (*Page) PubDate ¶
PubDate is when this page was or will be published. NOTE: This is currently used for search only and is not meant to be used directly in templates. We need to consolidate the dates in this struct. TODO(bep) see https://github.com/gohugoio/hugo/issues/3854
func (*Page) RSSLink ¶
func (*Page) RawContent ¶
func (*Page) ReadFrom ¶
func (*Page) ReadingTime ¶
func (*Page) Ref ¶
func (*Page) RelPermalink ¶
RelPermalink gets a URL to the resource relative to the host.
func (*Page) RelRef ¶
func (*Page) Render ¶
func (*Page) ResourceType ¶
func (*Page) SafeSaveSourceAs ¶
func (*Page) SaveSource ¶
func (*Page) SaveSourceAs ¶
func (*Page) Scratch ¶
Scratch returns the writable context associated with this Page.
func (*Page) SearchKeywords ¶
SearchKeywords implements the related.Document interface needed for fast page searches.
func (*Page) Section ¶
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 ¶
Sections returns this section's subsections, if any. Note that for non-sections, this method will always return an empty list.
func (*Page) SetSourceContent ¶
func (*Page) SetSourceMetaData ¶
func (*Page) Sites ¶
Sites is a convenience method to get all the Hugo sites/languages configured.
func (*Page) String ¶
func (*Page) Title ¶
func (*Page) TranslationKey ¶
TranslationKey returns the key used to map language translations of this page. It will use the translationKey set in front matter if set, or the content path and filename (excluding any language code and extension), e.g. "about/index". The Page Kind is always prepended.
func (*Page) Translations ¶
Translations returns the translations excluding the current Page.
func (*Page) Type ¶
func (*Page) URL ¶
func (*Page) UniqueID ¶
func (*Page) WordCount ¶
type PageCollections ¶
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 PageGenealogist ¶
type PageGenealogist interface { // Template example: // {{ $related := .RegularPages.Related . }} Related(doc related.Document) (Pages, error) // Template example: // {{ $related := .RegularPages.RelatedIndices . "tags" "date" }} RelatedIndices(doc related.Document, indices ...interface{}) (Pages, error) // Template example: // {{ $related := .RegularPages.RelatedTo ( keyVals "tags" "hugo", "rocks") ( keyVals "date" .Date ) }} RelatedTo(args ...types.KeyValues) (Pages, error) }
A PageGenealogist finds related pages in a page collection. This interface is implemented by Pages and PageGroup, which makes it available as `{{ .RegularPages.Related . }}` etc.
type PageGroup ¶
type PageGroup struct { Key interface{} Pages }
PageGroup represents a group of pages, grouped by the key. The key is typically a year or similar.
type PageMenus ¶
PageMenus is a dictionary of menus defined in the Pages.
type PageMeta ¶
type PageMeta struct { Weight int // contains filtered or unexported fields }
type PageOutput ¶
type PageOutput struct { *Page // contains filtered or unexported fields }
PageOutput represents one of potentially many output formats of a given Page.
func (*PageOutput) AlternativeOutputFormats ¶
func (p *PageOutput) AlternativeOutputFormats() (OutputFormats, error)
AlternativeOutputFormats 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 ¶
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 ¶
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 ¶
func (p *PageOutput) Render(layout ...string) template.HTML
func (*PageOutput) Resources ¶
func (p *PageOutput) Resources() resource.Resources
type Pager ¶
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 ¶
First returns the pager for the first page.
func (*Pager) HasNext ¶
HasNext tests whether there are page(s) after the current.
func (*Pager) HasPrev ¶
HasPrev tests whether there are page(s) before the current.
func (*Pager) Last ¶
Last returns the pager for the last page.
func (*Pager) Next ¶
Next returns the pager for the next page.
func (*Pager) NumberOfElements ¶
NumberOfElements gets the number of elements on this page.
func (*Pager) PageGroups ¶
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 ¶
PageNumber returns the current page's number in the pager sequence.
func (Pager) PageSize ¶
func (p Pager) PageSize() int
PageSize returns the size of each paginator page.
func (Pager) Pagers ¶
func (p Pager) Pagers() pagers
Pagers returns a list of pagers that can be used to build a pagination menu.
func (*Pager) Pages ¶
Pages returns the Pages on this page. Note: If this return a non-empty result, then PageGroups() will return empty.
func (*Pager) Prev ¶
Prev returns the pager for the previous page.
func (Pager) String ¶
func (Pager) TotalNumberOfElements ¶
func (p Pager) TotalNumberOfElements() int
TotalNumberOfElements returns the number of elements on all pages in this paginator.
func (Pager) TotalPages ¶
func (p Pager) TotalPages() int
TotalPages returns the number of pages in the paginator.
func (*Pager) URL ¶
URL returns the URL to the current page.
type Pages ¶
type Pages []*Page
func (Pages) ByDate ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (Pages) ByPublishDate ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Len returns the number of pages in the list.
func (Pages) Limit ¶
Limit limits the number of pages returned to n.
func (Pages) MergeByLanguage ¶
MergeByLanguage supplies missing translations in p1 with values from p2. The result is sorted by the default sort order for pages.
func (Pages) MergeByLanguageInterface ¶
MergeByLanguageInterface is the generic version of MergeByLanguage. It is here just so it can be called from the tpl package.
func (Pages) Next ¶
Next returns the next page reletive to the given page.
func (Pages) Prev ¶
Prev returns the previous page reletive to the given page.
func (Pages) Related ¶
Related searches all the configured indices with the search keywords from the supplied document.
func (Pages) RelatedIndices ¶
RelatedIndices searches the given indices with the search keywords from the supplied document.
func (Pages) RelatedTo ¶
RelatedTo searches the given indices with the corresponding values.
func (Pages) Reverse ¶
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 ¶
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 ¶
type PagesGroup ¶
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 ¶
func (psg PagesGroup) Len() int
Len returns the number of pages in the page group.
func (PagesGroup) Reverse ¶
func (p PagesGroup) Reverse() PagesGroup
Reverse reverses the order of this list of page groups.
type PermalinkOverrides ¶
type PermalinkOverrides map[string]pathPattern
PermalinkOverrides maps a section name to a PathPattern
type Permalinker ¶
Permalinker provides permalinks of both the relative and absolute kind.
type Position ¶
type Scratch ¶
type Scratch struct {
// contains filtered or unexported fields
}
Scratch is a writable context used for stateful operations in Page/Node rendering.
func (*Scratch) Add ¶
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) Delete ¶
Reset deletes the given key
func (*Scratch) Get ¶
Get returns a value previously set by Add or Set
func (*Scratch) GetSortedMapValues ¶
GetSortedMapValues returns a sorted map previously filled with SetInMap
func (*Scratch) Set ¶
Set stores a value with the given key in the Node context. This value can later be retrieved with Get.
func (*Scratch) SetInMap ¶
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 ¶
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 ¶
func (scp *ShortcodeWithPage) Get(key interface{}) interface{}
Get is a convenience method to look up shortcode parameters by its key.
func (*ShortcodeWithPage) Ref ¶
func (scp *ShortcodeWithPage) Ref(ref string) (string, error)
Ref is a shortcut to the Ref method on Page.
func (*ShortcodeWithPage) RelRef ¶
func (scp *ShortcodeWithPage) RelRef(ref string) (string, error)
RelRef is a shortcut to the RelRef method on Page.
func (*ShortcodeWithPage) Scratch ¶
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 ¶
func (scp *ShortcodeWithPage) Site() *SiteInfo
Site returns information about the current site.
type Site ¶
type Site struct { *PageCollections Taxonomies TaxonomyList 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.
- 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.
- Taxonomies are created via configuration and will present some aspect of the final page and typically a perm url.
- 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (*Site) NewPage ¶
func (*Site) NewPageFrom ¶
func (*Site) RegisterMediaTypes ¶
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 SiteInfo ¶
type SiteInfo struct { Taxonomies TaxonomyList Authors AuthorList Social SiteSocial *PageCollections 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 ¶
func (*SiteInfo) GetPage ¶
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 ¶
Home is a shortcut to the home page, equivalent to .Site.GetPage "home".
func (*SiteInfo) HomeAbsURL ¶
HomeAbsURL is a convenience method giving the absolute URL to the home page.
func (*SiteInfo) IsMultiLingual ¶
func (*SiteInfo) IsServer ¶
func (*SiteInfo) Param ¶
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 ¶
Ref will give an absolute URL to ref in the given Page.
func (*SiteInfo) RelRef ¶
RelRef will give an relative URL to ref in the given Page.
func (*SiteInfo) Sections ¶
Sections returns the top level sections.
func (*SiteInfo) ServerPort ¶
ServerPort returns the port part of the BaseURL, 0 if none found.
func (*SiteInfo) SitemapAbsURL ¶
SitemapAbsURL is a convenience method giving the absolute URL to the sitemap.
func (*SiteInfo) String ¶
type SiteInfos ¶
type SiteInfos []*SiteInfo
func (SiteInfos) First ¶
First is a convenience method to get the first Site, i.e. the main language.
type SiteSocial ¶
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 ¶
Sitemap configures the sitemap to be generated.
type Source ¶
type Taxonomy ¶
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 ¶
func (i Taxonomy) Alphabetical() OrderedTaxonomy
Alphabetical returns an ordered taxonomy sorted by key name.
func (Taxonomy) ByCount ¶
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 ¶
Count the weighted pages for the given key.
func (Taxonomy) Get ¶
func (i Taxonomy) Get(key string) WeightedPages
Get the weighted pages for the given key.
func (Taxonomy) TaxonomyArray ¶
func (i Taxonomy) TaxonomyArray() OrderedTaxonomy
TaxonomyArray returns an ordered taxonomy with a non defined order.
type TaxonomyList ¶
The TaxonomyList is a list of all taxonomies and their values e.g. List['tags'] => TagTaxonomy (from above)
func (TaxonomyList) String ¶
func (tl TaxonomyList) String() string
type Translations ¶
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 Video ¶
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 ¶
A WeightedPage is a Page with a weight.
func (WeightedPage) String ¶
func (w WeightedPage) String() string
type WeightedPages ¶
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 ¶
func (wp WeightedPages) Count() int
Count returns the number of pages in this weighted page set.
func (WeightedPages) Len ¶
func (wp WeightedPages) Len() int
func (WeightedPages) Less ¶
func (wp WeightedPages) Less(i, j int) bool
func (WeightedPages) Next ¶
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 ¶
func (wp WeightedPages) Pages() Pages
Pages returns the Pages in this weighted page set.
func (WeightedPages) Prev ¶
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 ¶
func (wp WeightedPages) Sort()
Sort stable sorts this weighted page set.
func (WeightedPages) Swap ¶
func (wp WeightedPages) Swap(i, j int)
Source Files ¶
alias.go author.go config.go fileInfo.go gitinfo.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_bundler.go page_bundler_capture.go page_bundler_handlers.go page_collections.go page_output.go page_paths.go page_resource.go pagesPrevNext.go pages_language_merge.go pages_related.go pagination.go permalinker.go permalinks.go prune_resources.go scratch.go shortcode.go shortcodeparser.go site.go site_output.go site_render.go site_sections.go sitemap.go taxonomy.go translations.go
Directories ¶
Path | Synopsis |
---|---|
hugolib/pagemeta |
- Version
- v0.38.2
- Published
- Apr 9, 2018
- Platform
- linux/amd64
- Imports
- 53 packages
- Last checked
- 1 minute ago –
Tools for package owners.