2020-02-06 13:02:49 +01:00
---
title: hugo
description: The `hugo` function provides easy access to Hugo-related data.
keywords: []
categories: [functions]
menu:
docs:
2023-05-22 16:43:12 +02:00
parent: functions
2020-02-06 13:02:49 +01:00
toc:
signature: ["hugo"]
relatedfuncs: []
---
2020-06-16 14:18:51 +02:00
2020-02-06 13:02:49 +01:00
`hugo` returns an instance that contains the following functions:
2023-05-27 16:59:59 +02:00
`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` ).
2020-02-06 13:02:49 +01:00
2023-05-27 16:59:59 +02:00
`hugo.CommitHash`
: (`string` ) The Git commit hash of the Hugo binary (e.g., `0a95d6704a8ac8d41cc5ca8fffaad8c5c7a3754a` ).
2020-02-06 13:02:49 +01:00
2023-05-27 16:59:59 +02:00
`hugo.Deps`
: (`[]*hugo.Dependency` ) See [hugo.Deps ](#hugodeps ).
2020-02-06 13:02:49 +01:00
2023-05-27 16:59:59 +02:00
`hugo.Environment`
: (`string` ) The current running environment as defined through the `--environment` CLI flag (e.g., `development` , `production` ).
2020-02-06 13:02:49 +01:00
2023-05-27 16:59:59 +02:00
`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">` ).
2020-02-06 13:02:49 +01:00
2023-05-27 16:59:59 +02:00
`hugo.GoVersion`
: (`string` ) The Go version used to compile the Hugo binary (e.g., `go1.20.4` ). {{< new-in "0.101.0" >}}
2020-02-06 13:02:49 +01:00
2023-05-27 16:59:59 +02:00
`hugo.IsExtended`
: (`bool` ) Returns `true` if the Hugo binary is the extended version.
2021-04-20 20:21:45 +02:00
2023-05-27 16:59:59 +02:00
`hugo.IsProduction`
: (`bool` ) Returns `true` if `hugo.Environment` is set to the production environment.
2020-02-06 13:02:49 +01:00
2023-05-27 16:59:59 +02:00
`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" >}}
2022-02-14 12:58:42 +01:00
## hugo.Deps
{{< new-in "0.92.0" >}}
`hugo.Deps` returns a list of dependencies for a project (either Hugo Modules or local theme components).
2022-03-26 11:04:57 +02:00
Each dependency contains:
2022-02-14 12:58:42 +01:00
2023-05-27 16:59:59 +02:00
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` ).
2022-02-14 12:58:42 +01:00
2023-05-27 16:59:59 +02:00
Path
: (`string` ) The module path or the path below your `themes` directory (e.g., `github.com/gohugoio/hugo-mod-jslibs-dist/popperjs/v2` ).
2022-03-26 11:04:57 +02:00
2023-05-27 16:59:59 +02:00
Replace
: (`*hugo.Dependency` ) Replaced by this dependency.
2022-03-26 11:04:57 +02:00
2023-05-27 16:59:59 +02:00
Time
: (`time.Time` ) The time that the version was created (e.g., `2022-02-13 15:11:28 +0000 UTC` ).
2022-02-14 12:58:42 +01:00
2023-05-27 16:59:59 +02:00
Vendor
: (`bool` ) Returns `true` if the dependency is vendored.
2022-02-14 12:58:42 +01:00
2023-05-27 16:59:59 +02:00
Version
: (`string` ) The module version (e.g., `v2.21100.20000` ).
2022-02-14 12:58:42 +01:00
An example table listing the dependencies:
```html
2023-05-27 16:59:59 +02:00
<h2>Dependencies</h2>
2022-02-14 12:58:42 +01:00
<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>
2023-05-22 16:43:12 +02:00
<td>{{ with $element.Owner }}{{ .Path }}{{ end }}</td>
2022-02-14 12:58:42 +01:00
<td>
{{ $element.Path }}
2023-05-22 16:43:12 +02:00
{{ with $element.Replace }}
2022-02-14 12:58:42 +01:00
=> {{ .Path }}
{{ end }}
</td>
<td>{{ $element.Version }}</td>
<td>{{ with $element.Time }}{{ . }}{{ end }}</td>
<td>{{ $element.Vendor }}</td>
</tr>
{{ end }}
</tbody>
</table>
2022-06-28 20:51:33 +02:00
```