Documentation ¶
Index ¶
- Constants
- Variables
- func HandlerMatch(h Handler, ext string) bool
- func LoadConfig(fs afero.Fs, relativeSourcePath, configFilename string) (*viper.Viper, error)
- func RegisterHandler(h Handler)
- type Author
- type AuthorList
- type AuthorSocial
- type BuildCfg
- type Handle
- type HandleResults
- type HandledResult
- type Handler
- type HugoInfo
- type HugoSites
- type Image
- type Menu
- type MenuEntry
- type Menus
- type MetaHandle
- type MetaHandler
- 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) Extension() string
- 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) Hugo() *HugoInfo
- 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) 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) Now() time.Time
- 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) Permalink() string
- func (p *Page) Plain() string
- func (p *Page) PlainWords() []string
- func (p *Page) ProcessShortcodes()
- 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 (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) Section() string
- func (p *Page) SetSourceContent(content []byte)
- func (p *Page) SetSourceMetaData(in interface{}, mark rune) (err error)
- func (p *Page) String() string
- func (p *Page) TargetPath() (outfile 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 PageGroup
- type PageMenus
- type PageMeta
- type PageOutput
- 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 (ps Pages) FindPagePos(page *Page) int
- func (ps Pages) FindPagePosByFilePath(inPath string) int
- 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) 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
- 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) SitemapAbsURL() string
- func (s *SiteInfo) SourceRelativeLink(ref string, currentPage *Page) (string, error)
- func (s *SiteInfo) SourceRelativeLinkFile(ref string, currentPage *Page) (string, error)
- 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" // 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")
Functions ¶
func HandlerMatch ¶
func LoadConfig ¶
LoadConfig loads Hugo configuration into a new Viper and then adds a set of defaults.
func RegisterHandler ¶
func RegisterHandler(h Handler)
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 { // 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 ¶
type Handle struct {
// contains filtered or unexported fields
}
func (Handle) Extensions ¶
type HandleResults ¶
type HandleResults chan<- HandledResult
type HandledResult ¶
type HandledResult struct {
// contains filtered or unexported fields
}
func (HandledResult) Page ¶
func (h HandledResult) Page() *Page
func (HandledResult) String ¶
func (h HandledResult) String() string
type Handler ¶
type Handler interface { FileConvert(*source.File, *Site) HandledResult PageConvert(*Page) HandledResult Read(*source.File, *Site) HandledResult Extensions() []string }
func FindHandler ¶
type HugoSites ¶
HugoSites represents the sites to build. Each site represents a language.
func NewHugoSites ¶
NewHugoSites creates HugoSites from the given config.
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 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 (*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 MetaHandle ¶
type MetaHandle struct {
// contains filtered or unexported fields
}
func NewMetaHandler ¶
func NewMetaHandler(in string) *MetaHandle
func (*MetaHandle) Convert ¶
func (mh *MetaHandle) Convert(i interface{}, s *Site, results HandleResults)
func (*MetaHandle) Handler ¶
func (mh *MetaHandle) Handler() Handler
func (*MetaHandle) Read ¶
func (mh *MetaHandle) Read(f *source.File, s *Site, results HandleResults)
type MetaHandler ¶
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 ¶
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 }
And 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
Permalink 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 // 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 ¶
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) Authors ¶
func (p *Page) Authors() AuthorList
func (*Page) FullFilePath ¶
func (*Page) FuzzyWordCount ¶
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) OutputFormats ¶
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) PlainWords ¶
func (*Page) ProcessShortcodes ¶
func (p *Page) ProcessShortcodes()
func (*Page) RawContent ¶
func (*Page) ReadingTime ¶
func (*Page) RelPermalink ¶
RelPermalink gets a URL to the resource relative to the host.
func (*Page) SafeSaveSourceAs ¶
func (*Page) SaveSource ¶
func (*Page) SaveSourceAs ¶
func (*Page) SetSourceContent ¶
func (*Page) SetSourceMetaData ¶
func (*Page) TargetPath ¶
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 PageGroup ¶
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 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)
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 ¶
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"].
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) FindPagePos ¶
FindPagePos Given a page, it will find the position in Pages will return -1 if not found
func (Pages) FindPagePosByFilePath ¶
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) 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 ¶
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 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.
- 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.
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.
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) 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 Sections Taxonomy *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) GetPage ¶
GetPage looks up a index page of a given type in the path given. This method may support regular pages in the future, but currently it is a convenient way of getting the home page or a section from a template:
{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }}
This will return nil when no page could be found.
The valid page types are: home, section, taxonomy and taxonomyTerm
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) SitemapAbsURL ¶
SitemapAbsURL is a convenience method giving the absolute URL to the sitemap.
func (*SiteInfo) SourceRelativeLink ¶
SourceRelativeLink attempts to convert any source page relative links (like [../another.md]) into absolute links
func (*SiteInfo) SourceRelativeLinkFile ¶
SourceRelativeLinkFile attempts to convert any non-md source relative links (like [../another.gif]) into absolute links
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
- 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
- sitemap.go
- taxonomy.go
- translations.go