Syntax of functions and their alias

Dear all,

using Hugo for quite some time I saw that the documentation was reordered from time to time. For some years I am working on a book about Hugo trying to catch up with the pace of development. I am again working on it and have a question about functions.

In the documentation functions are grouped by their syntax in so far as eg. all time-functions are grouped together: time.Format, time.Duration, time.Now etc. But functions have aliases like dateFormat, duration, now.

I guess that most people use the aliases in their projects as I do. In fact I didn’t know that they were aliases when I started to use Hugo, and I didn’t know it for quite some time.

As most code examples use aliases I guess that it is correct and recommended to use the aliases.

Is that correct or do you intend to promote the use of the verbose syntax in the future?


No. The aliases for commonly used functions exist for a good reason: brevity.

Do tell me why on Earth you would want to write more ? As if the syntax wasn’t verbose enough :rofl:

I won’t. :wink: I was puzzled why functions are listed according to their complete syntax in the navigation of the documentation, while everyone looks for the alias as it is more common.

When writing a printed book there is no search form and I have to consider whether I want to have compare.Default in my index or default. So I asked whether the developers tend to recommend the verbose syntax or the common terse one. Having both in the index is an option I would like to avoid.

As a non programmer I am still puzzled by variations like the above or like {{}} and {{}}.

Rest assured, even people with a background in programmation can stay puzzled :roll_eyes: :roll_eyes: :roll_eyes: :roll_eyes:

1 Like

If you mean, “why functions are listed according to their canonical name”, it because they should be listed according to their canonical name.

If you’re writing a book you should include a brief discussion of context. If you understand context, and read the documentation for the global site function, neither you nor your readers should be puzzled.

1 Like

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