Documentation ¶
Index ¶
- Constants
- Variables
- func LoadConfig(fs afero.Fs, relativeSourcePath, configFilename string) (*viper.Viper, error)
- type Author
- type AuthorList
- type AuthorSocial
- type BuildCfg
- type HugoInfo
- type HugoSites
- type Image
- type Menu
- type MenuEntry
- type Menus
- type Multilingual
- type OrderedTaxonomy
- type OrderedTaxonomyEntry
- type OutputFormat
- 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) 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 (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) 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
- type Site
- 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) 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 SiteSocial
- type Sitemap
- type Source
- type Taxonomy
- type TaxonomyList
- type Translations
- type URLPath
- 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 ¶
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 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 ¶ added in v0.20.1
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) GetContentPage ¶ added in v0.25.1
GetContentPage finds a Page with content given the absolute filename. Returns nil if none found.
func (*HugoSites) IsMultihost ¶ added in v0.31.1
func (*HugoSites) PrintProcessingStats ¶ added in v0.32.1
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.
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).
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.
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 ¶ added in v0.20.1
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 ¶ added in v0.20.1
func (o OutputFormat) MediaType() media.Type
MediaType returns this OutputFormat's MediaType (MIME type).
func (OutputFormat) Name ¶ added in v0.20.1
func (o OutputFormat) Name() string
Name returns this OutputFormat's name, i.e. HTML, AMP, JSON etc.
func (*OutputFormat) Permalink ¶ added in v0.20.1
func (o *OutputFormat) Permalink() string
Permalink returns the absolute permalink to this output format.
func (*OutputFormat) RelPermalink ¶ added in v0.20.1
func (o *OutputFormat) RelPermalink() string
RelPermalink returns the relative permalink to this output format.
type OutputFormats ¶ added in v0.20.1
type OutputFormats []*OutputFormat
OutputFormats holds a list of the relevant output formats for a given resource.
func (OutputFormats) Get ¶ added in v0.20.1
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 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:"-"` 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 ¶
AllTranslations returns all translations, including the current Page.
func (*Page) AlternativeOutputFormats ¶ added in v0.20.1
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) Authors ¶
func (p *Page) Authors() AuthorList
func (*Page) CurrentSection ¶ added in v0.25.1
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 ¶ added in v0.27.1
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) HasShortcode ¶ added in v0.27.1
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) InSection ¶ added in v0.22.1
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 ¶ added in v0.25.1
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 ¶ added in v0.25.1
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) 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) IsRenderable ¶
func (*Page) IsTranslated ¶
IsTranslated returns whether this content file is translated to other language(s).
func (*Page) LanguagePrefix ¶
func (*Page) Name ¶ added in v0.36.1
See resource.Resource This value is used, by default, in Resources.ByPrefix etc.
func (*Page) OutputFormats ¶ added in v0.20.1
func (p *Page) OutputFormats() OutputFormats
OutputFormats gives the output formats for this Page.
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) Parent ¶ added in v0.22.1
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) PlainWords ¶
func (*Page) PubDate ¶ added in v0.27.1
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) RawContent ¶
func (*Page) ReadingTime ¶
func (*Page) RelPermalink ¶
RelPermalink gets a URL to the resource relative to the host.
func (*Page) ResourceType ¶ added in v0.32.1
func (*Page) SafeSaveSourceAs ¶
func (*Page) SaveSource ¶
func (*Page) SaveSourceAs ¶
func (*Page) SearchKeywords ¶ added in v0.27.1
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 ¶ added in v0.22.1
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) TranslationKey ¶ added in v0.31.1
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.
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 ¶ added in v0.27.1
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 PageOutput ¶ added in v0.20.1
type PageOutput struct { *Page // contains filtered or unexported fields }
PageOutput represents one of potentially many output formats of a given Page.
func (*PageOutput) AlternativeOutputFormats ¶ added in v0.20.1
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 ¶ added in v0.20.1
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 ¶ added in v0.20.1
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 ¶ added in v0.20.1
func (p *PageOutput) Render(layout ...string) template.HTML
func (*PageOutput) Resources ¶ added in v0.32.1
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) 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) 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.
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) 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) Related ¶ added in v0.27.1
Related searches all the configured indices with the search keywords from the supplied document.
func (Pages) RelatedIndices ¶ added in v0.27.1
RelatedIndices searches the given indices with the search keywords from the supplied document.
func (Pages) RelatedTo ¶ added in v0.27.1
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.
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 ¶ added in v0.20.1
Permalinker provides permalinks of both the relative and absolute kind.
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) GetSortedMapValues ¶
GetSortedMapValues returns a sorted map previously filled with SetInMap
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 ¶ added in v0.20.1
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 ¶ added in v0.20.1
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 ¶ added in v0.20.1
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 ¶ added in v0.20.1
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) NewPageFrom ¶ added in v0.20.1
func (*Site) RegisterMediaTypes ¶ added in v0.20.1
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) 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 ¶ added in v0.22.1
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) 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) ServerPort ¶ added in v0.31.1
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.
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 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) 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_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