你可以把 Hugo 開發理解成 Hugo 語言,他封裝了 Go 語言的功能提供給模板使用,並且自行解析模板、reflect 變數,可以說是自成一家的語言了。Go 語言的功能僅有有限的提供,因此即使你熟悉 Go/Go template,使用 Hugo 還是得看文檔才會使用。
Hugo 的 API 分為兩種:Methods and Functions。Methods 是 stateful,綁定在物件上,如 .IsPage 是綁定在 .Page 物件上,functions 則為 stateless 可以直接呼叫,也能用於 archetype 中。
以下索引整理自 Hugo 官方文檔,本站不重複撰寫這些內容,直接連回官方頁面查閱即可。
Hugo Pipes
- Introduction
- Bundling
- Fingerprinting
- JavaScript building
- Minification
- PostCSS
- Resource from string
- Resource from template
- Transpile Sass to CSS
Methods
Duration
Menu
Menu entry
Output format
Page
- Aliases
- AllTranslations
- AlternativeOutputFormats
- Ancestors
- BundleType
- CodeOwners
- Content
- ContentWithoutSummary
- CurrentSection
- Data
- Date
- Description
- Draft
- Eq
- ExpiryDate
- File
- FirstSection
- Fragments
- FuzzyWordCount
- GetPage
- GetTerms
- GitInfo
- HasMenuCurrent
- HasShortcode
- HeadingsFiltered
- InSection
- IsAncestor
- IsBranch
- IsDescendant
- IsHome
- IsMenuCurrent
- IsNode
- IsPage
- IsSection
- IsTranslated
- Keywords
- Kind
- Language
- Lastmod
- Layout
- Len
- LinkTitle
- Next
- NextInSection
- OutputFormats
- Page
- Pages
- Paginate
- Paginator
- Param
- Params
- Parent
- Path
- Permalink
- Plain
- PlainWords
- Prev
- PrevInSection
- PublishDate
- RawContent
- ReadingTime
- Ref
- RegularPages
- RegularPagesRecursive
- RelPermalink
- RelRef
- Render
- RenderShortcodes
- RenderString
- Resources
- Rotate
- Scratch
- Section
- Sections
- Site
- Sitemap
- Sites
- Slug
- Store
- Summary
- TableOfContents
- Title
- TranslationKey
- Translations
- Truncated
- Type
- Weight
- WordCount
Pager
- First
- HasNext
- HasPrev
- Last
- Next
- NumberOfElements
- PageGroups
- PageNumber
- PagerSize
- Pagers
- Pages
- Prev
- TotalNumberOfElements
- TotalPages
- URL
Pages
- ByDate
- ByExpiryDate
- ByLanguage
- ByLastmod
- ByLength
- ByLinkTitle
- ByParam
- ByPublishDate
- ByTitle
- ByWeight
- GroupBy
- GroupByDate
- GroupByExpiryDate
- GroupByLastmod
- GroupByParam
- GroupByParamDate
- GroupByPublishDate
- Len
- Limit
- Next
- Prev
- Related
- Reverse
Resource
- Colors
- Content
- Crop
- Data
- Err
- Exif
- Fill
- Filter
- Fit
- Height
- MediaType
- Meta
- Name
- Params
- Permalink
- Process
- Publish
- RelPermalink
- Resize
- ResourceType
- Title
- Width
Shortcode
Site
- AllPages
- BaseURL
- BuildDrafts
- Config
- Copyright
- Data
- Dimension
- GetPage
- Home
- IsDefault
- Language
- LanguagePrefix
- Languages
- Lastmod
- MainSections
- Menus
- Pages
- Param
- Params
- RegularPages
- Role
- Sections
- Sites
- Store
- Taxonomies
- Title
- Version
Taxonomy
Time
- Add
- AddDate
- After
- Before
- Day
- Equal
- Format
- Hour
- IsDST
- IsZero
- Local
- Minute
- Month
- Nanosecond
- Round
- Second
- Sub
- Truncate
- UTC
- Unix
- UnixMicro
- UnixMilli
- UnixNano
- Weekday
- Year
- YearDay
Functions
cast
collections
- collections.After
- collections.Append
- collections.Apply
- collections.Complement
- collections.D
- collections.Delimit
- collections.Dictionary
- collections.First
- collections.Group
- collections.In
- collections.Index
- collections.Intersect
- collections.IsSet
- collections.KeyVals
- collections.Last
- collections.Merge
- collections.NewScratch
- collections.Querify
- collections.Reverse
- collections.Seq
- collections.Shuffle
- collections.Slice
- collections.Sort
- collections.SymDiff
- collections.Union
- collections.Uniq
- collections.Where
compare
crypto
css
debug
diagrams
encoding
fmt
global
go template
hash
hugo
- hugo.BuildDate
- hugo.CommitHash
- hugo.Data
- hugo.Deps
- hugo.Environment
- hugo.Generator
- hugo.GoVersion
- hugo.IsDevelopment
- hugo.IsExtended
- hugo.IsMultihost
- hugo.IsMultilingual
- hugo.IsProduction
- hugo.IsServer
- hugo.Sites
- hugo.Store
- hugo.Version
- hugo.WorkingDir
images
- images.AutoOrient
- images.Brightness
- images.ColorBalance
- images.Colorize
- images.Config
- images.Contrast
- images.Dither
- images.Filter
- images.Gamma
- images.GaussianBlur
- images.Grayscale
- images.Hue
- images.Invert
- images.Mask
- images.Opacity
- images.Overlay
- images.Padding
- images.Pixelate
- images.Process
- images.QR
- images.Saturation
- images.Sepia
- images.Sigmoid
- images.Text
- images.UnsharpMask
inflect
js
lang
- lang.FormatAccounting
- lang.FormatCurrency
- lang.FormatNumber
- lang.FormatNumberCustom
- lang.FormatPercent
- lang.Merge
- lang.Translate
math
- math.Abs
- math.Acos
- math.Add
- math.Asin
- math.Atan
- math.Atan2
- math.Ceil
- math.Cos
- math.Counter
- math.Div
- math.Floor
- math.Log
- math.Max
- math.MaxInt64
- math.Min
- math.Mod
- math.ModBool
- math.Mul
- math.Pi
- math.Pow
- math.Product
- math.Rand
- math.Round
- math.Sin
- math.Sqrt
- math.Sub
- math.Sum
- math.Tan
- math.ToDegrees
- math.ToRadians
openapi3
os
partials
path
reflect
- reflect.IsImageResource
- reflect.IsImageResourceProcessable
- reflect.IsImageResourceWithMeta
- reflect.IsMap
- reflect.IsPage
- reflect.IsResource
- reflect.IsSite
- reflect.IsSlice
resources
- resources.ByType
- resources.Concat
- resources.Copy
- resources.ExecuteAsTemplate
- resources.Fingerprint
- resources.FromString
- resources.Get
- resources.GetMatch
- resources.GetRemote
- resources.Match
- resources.Minify
- resources.PostProcess
safe
strings
- strings.Chomp
- strings.Contains
- strings.ContainsAny
- strings.ContainsNonSpace
- strings.Count
- strings.CountRunes
- strings.CountWords
- strings.FindRESubmatch
- strings.FindRE
- strings.FirstUpper
- strings.HasPrefix
- strings.HasSuffix
- strings.Repeat
- strings.Replace
- strings.ReplacePairs
- strings.ReplaceRE
- strings.RuneCount
- strings.SliceString
- strings.Split
- strings.Substr
- strings.Title
- strings.ToLower
- strings.ToUpper
- strings.Trim
- strings.TrimLeft
- strings.TrimPrefix
- strings.TrimRight
- strings.TrimSpace
- strings.TrimSuffix
- strings.Truncate
templates
time
transform
- transform.CanHighlight
- transform.Emojify
- transform.HTMLEscape
- transform.HTMLUnescape
- transform.HTMLToMarkdown
- transform.Highlight
- transform.HighlightCodeBlock
- transform.Markdownify
- transform.Plainify
- transform.PortableText
- transform.Remarshal
- transform.ToMath
- transform.Unmarshal
- transform.XMLEscape