mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
d3927310d5
1798dc0d5 Update theme 403fa716e Update CLI documentation (#2092) aade5a09e Correct media subtype example 53cd9dea6 netlify: Hugo 0.112.3 b78b86cb1 Add source/target warning to resources.Copy (#2091) 50c299729 netlify: Hugo 0.112.2 73197046f Change config.xxx to hugo.xxx throughout the documentation (#2090) d489d4c6f Add hugo.WorkingDir to docs (#2089) 7487df809 Fix typos (#2088) 6d0572cd6 netlify: Hugo 0.112.1 6838600b2 netlify: Hugo 0.112.0 513e7a80f Merge branch 'tempv0.112.0' 91eb44275 Some more about 0.112.0 bd3b33a27 docs: Regen docshelper fb3027daf docs: Regen CLI docs 8e7b8e987 Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb' a942ceef4 tpl/tplimpl: Add img loading attribute to figure shortcode (#10927) 0e0c7b25e tpl/urls: Return empty string when JoinPath has zero args 310ce949a tpl/urls: Add JoinPath template function ae435ca77 tpl: Add math.Abs f340139f8 Revert "Update syntax-highlighting.md (#10929)" (#10930) 917a0e24d Update syntax-highlighting.md (#10929) git-subtree-dir: docs git-subtree-split: 1798dc0d54ce048dd975863b490cd809ef14268a
105 lines
3.1 KiB
Markdown
105 lines
3.1 KiB
Markdown
---
|
|
title: hugo
|
|
description: The `hugo` function provides easy access to Hugo-related data.
|
|
keywords: []
|
|
categories: [functions]
|
|
menu:
|
|
docs:
|
|
parent: functions
|
|
toc:
|
|
signature: ["hugo"]
|
|
relatedfuncs: []
|
|
---
|
|
|
|
`hugo` returns an instance that contains the following functions:
|
|
|
|
`hugo.BuildDate`
|
|
: (`string`) The compile date of the current Hugo binary formatted per [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) (e.g., `2023-05-23T08:14:20Z`).
|
|
|
|
`hugo.CommitHash`
|
|
: (`string`) The Git commit hash of the Hugo binary (e.g., `0a95d6704a8ac8d41cc5ca8fffaad8c5c7a3754a`).
|
|
|
|
`hugo.Deps`
|
|
: (`[]*hugo.Dependency`) See [hugo.Deps](#hugodeps).
|
|
|
|
`hugo.Environment`
|
|
: (`string`) The current running environment as defined through the `--environment` CLI flag (e.g., `development`, `production`).
|
|
|
|
`hugo.Generator`
|
|
: (`template.HTML`) Renders an HTML `meta` element identifying the software that generated the site (e.g., `<meta name="generator" content="Hugo 0.112.0">`).
|
|
|
|
`hugo.GoVersion`
|
|
: (`string`) The Go version used to compile the Hugo binary (e.g., `go1.20.4`). {{< new-in "0.101.0" >}}
|
|
|
|
`hugo.IsExtended`
|
|
: (`bool`) Returns `true` if the Hugo binary is the extended version.
|
|
|
|
`hugo.IsProduction`
|
|
: (`bool`) Returns `true` if `hugo.Environment` is set to the production environment.
|
|
|
|
`hugo.Version`
|
|
: (`hugo.VersionString`) The current version of the Hugo binary (e.g., `0.112.1`).
|
|
|
|
`hugo.WorkingDir`
|
|
: (`string`) The project working directory (e.g., `/home/user/projects/my-hugo-site`). {{< new-in "0.112.0" >}}
|
|
|
|
## hugo.Deps
|
|
|
|
{{< new-in "0.92.0" >}}
|
|
|
|
`hugo.Deps` returns a list of dependencies for a project (either Hugo Modules or local theme components).
|
|
|
|
Each dependency contains:
|
|
|
|
Owner
|
|
: (`*hugo.Dependency`) In the dependency tree, this is the first module that defines this module as a dependency (e.g., `github.com/gohugoio/hugo-mod-bootstrap-scss/v5`).
|
|
|
|
Path
|
|
: (`string`) The module path or the path below your `themes` directory (e.g., `github.com/gohugoio/hugo-mod-jslibs-dist/popperjs/v2`).
|
|
|
|
Replace
|
|
: (`*hugo.Dependency`) Replaced by this dependency.
|
|
|
|
Time
|
|
: (`time.Time`) The time that the version was created (e.g., `2022-02-13 15:11:28 +0000 UTC`).
|
|
|
|
Vendor
|
|
: (`bool`) Returns `true` if the dependency is vendored.
|
|
|
|
Version
|
|
: (`string`) The module version (e.g., `v2.21100.20000`).
|
|
|
|
An example table listing the dependencies:
|
|
|
|
```html
|
|
<h2>Dependencies</h2>
|
|
<table class="table table-dark">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">#</th>
|
|
<th scope="col">Owner</th>
|
|
<th scope="col">Path</th>
|
|
<th scope="col">Version</th>
|
|
<th scope="col">Time</th>
|
|
<th scope="col">Vendor</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{ range $index, $element := hugo.Deps }}
|
|
<tr>
|
|
<th scope="row">{{ add $index 1 }}</th>
|
|
<td>{{ with $element.Owner }}{{ .Path }}{{ end }}</td>
|
|
<td>
|
|
{{ $element.Path }}
|
|
{{ with $element.Replace }}
|
|
=> {{ .Path }}
|
|
{{ end }}
|
|
</td>
|
|
<td>{{ $element.Version }}</td>
|
|
<td>{{ with $element.Time }}{{ . }}{{ end }}</td>
|
|
<td>{{ $element.Vendor }}</td>
|
|
</tr>
|
|
{{ end }}
|
|
</tbody>
|
|
</table>
|
|
```
|