What variables are exposed to the archetype file when using `hugo new` like `.Name`?

I understand this question was asked previously 4 years ago and wasn’t replied to:
Variables in archetype

But I noticed .Name and .Date variables in the example given in the official Archetypes Documentation. And .Name actually refers here to the directory’s name.

I assume there are more variables exposed with hugo new command?

I tried searching the variables documentation but couldn’t find anything.

I would really appreciate if someone can point me to the right resource. Thanks!

1 Like


The full Hugo .Site and all of Hugo’s template funcs can be used in the archetype file.

1 Like



And, how is the .Name exposed? It’s specific to the page being created, right?

It’s from the argument passed to hugo new.

Are there other such variables based on args passed in CLI?

hugo new --kind "other" foo/my-post.md

Variable Type Value
.Date string 2021-08-07T10:11:59-07:00
.Dir string foo/
.Name string my-post
.Type string other

The .File variables are also available, with the exception of .File.Lang.

{{ .File.BaseFileName }}
{{ .File.ContentBaseName }}
{{ .File.Dir }}
{{ .File.Ext }}
{{ .File.LogicalName }}
{{ .File.Path }}
{{ .File.TranslationBaseName }}
{{ .File.UniqueID }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.