Documentation ¶
Index ¶
Constants ¶
const ( KindPage = "page" KindHome = "home" KindSection = "section" )
Variables ¶
var DefaultFormats = Formats{ HTMLFormat, }
DefaultFormats contains the default output formats supported by Hugo.
var DefaultTypes = Types{ HTMLType, }
DefaultTypes is the default media types supported by Hugo.
var HTMLFormat = Format{ Name: "HTML", MediaType: HTMLType, BaseName: "index", }
HTMLFormat An ordered list of built-in output formats.
var HTMLType = newMediaType("text", "html")
Functions ¶
func CreateSiteOutputFormats ¶
func UniqueStringsReuse ¶
UniqueStringsReuse returns a slice with any duplicates removed. It will modify the input slice.
Types ¶
type Format ¶
type Format struct { // The Name is used as an identifier. Internal output formats (i.e. HTML and RSS) // can be overridden by providing a new definition for those types. Name string `json:"name"` MediaType Type `json:"-"` // The base output file name used when not using "ugly URLs", defaults to "index". BaseName string `json:"baseName"` }
Format represents an output representation, usually to a file on disk.
type Formats ¶
type Formats []Format
Formats is a slice of Format.
func DecodeFormats ¶
DecodeFormats takes a list of output format configurations and merges those, in the order given, with the Hugo defaults as the last resort.
func (Formats) FromFilename ¶
FromFilename gets a Format given a filename.
type LayoutDescriptor ¶
type LayoutDescriptor struct { Type string Section string // E.g. "page", but also used for the _markup render kinds, e.g. "render-image". Kind string // Comma-separated list of kind variants, e.g. "go,json" as variants which would find "render-codeblock-go.html" KindVariants string Lang string Layout string // LayoutOverride indicates what we should only look for the above layout. LayoutOverride bool RenderingHook bool Baseof bool }
LayoutDescriptor describes how a layout should be chosen. This is typically built from a Page.
type LayoutHandler ¶
type LayoutHandler struct {
// contains filtered or unexported fields
}
LayoutHandler calculates the layout template to use to render a given output type.
func NewLayoutHandler ¶
func NewLayoutHandler() *LayoutHandler
NewLayoutHandler creates a new LayoutHandler.
func (*LayoutHandler) For ¶
func (l *LayoutHandler) For(d LayoutDescriptor, f Format) ([]string, error)
For returns a layout for the given LayoutDescriptor and options. Layouts are rendered and cached internally.
type OutputFormat ¶
type OutputFormat struct { // Rel contains 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 Format Format // contains filtered or unexported fields }
OutputFormat links to a representation of a resource.
func NewOutputFormat ¶
func NewOutputFormat(relPermalink, permalink string, f Format) OutputFormat
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 page.
type TargetPaths ¶
type TargetPaths struct { // Where to store the file on disk relative to the publish dir. OS slashes. TargetFilename string // The directory to write sub-resources of the above. SubResourceBaseTarget string // The base for creating links to sub-resources of the above. SubResourceBaseLink string // The relative permalink to this resources. Unix slashes. Link string }
func (TargetPaths) GetBasePath ¶
func (p TargetPaths) GetBasePath(isRelativeURL bool) string
GetBasePath returns any path element in baseURL if needed.
func (TargetPaths) PermalinkForBaseURL ¶
func (p TargetPaths) PermalinkForBaseURL(link, baseURL string) string
PermalinkForBaseURL creates a permalink from the given link and baseURL.
func (TargetPaths) PermalinkForOutputFormat ¶
func (p TargetPaths) PermalinkForOutputFormat() string
func (TargetPaths) PrependBasePath ¶
func (p TargetPaths) PrependBasePath(rel string, isAbs bool) string
PrependBasePath prepends any baseURL sub-folder to the given resource
func (TargetPaths) RelPermalink ¶
func (p TargetPaths) RelPermalink() string
type Type ¶
type Type struct { MainType string `json:"mainType"` // i.e. text SubType string `json:"subType"` // i.e. html Delimiter string `json:"delimiter"` // e.g. "." }
Type (also known as MIME type and content type) is a two-part identifier for file formats and format contents transmitted on the Internet. For Hugo's use case, we use the top-level type name / subtype name + suffix. One example would be application/svg+xml If suffix is not provided, the sub type will be used. See // https://en.wikipedia.org/wiki/Media_type
func (Type) FullSuffix ¶
func (Type) Type ¶
Type returns a string representing the main- and sub-type of a media type, e.g. "text/css". A suffix identifier will be appended after a "+" if set, e.g. "image/svg+xml". Hugo will register a set of default media types. These can be overridden by the user in the configuration, by defining a media type with the same Type.