Well there is always: hugo --help for a top-level list of commands.
The docs have a list, and if you want shell completion you can generate a completions file via:
hugo completion \<shell> where <shell> is one of bash, fish, zsh, or powershell. Take the output of that command and ensure it is sourced by your shell (how is system and shell dependent) and you type hugo followed by the Tab key you get a list of command, and so on for subcommands.
There is not a hugo command for create a new directory under layouts though. For that use mkdir from your OS CLI, or using a GUI.
If you are familiar with the make command it may be helpful to think of hugo being like make with a couple of convenience functions for getting started, rather than thinking of it as a project builder.
Not with Hugo, as this is not a hugo task. mkdir layouts/directoryname on a shell CLI should do the trick. On Windows/Max it’s probably a different command.
there are Hugo specific command like to create an archetype file and then use the archetype type to create a new md file etc
One can create an archetype and then use that archetype that I know from the docs but what other types I can create and use?
can I create a data.json template and apply the template to the data fetched from and api in Hugo when running Hugo new can I combine Hugo new with Hugo get data from url command to prepopulate a file?
or the archetype and html layout the only type one can apply when running Hugo new command?
new content based on archetypes (which are files that define how new content looks like) (hugo new | Hugo)
There is no other command to create new things.
That question about data.json is too broad to say anything useful. What I could think of is some form of frontmatter that gets created on hugo new saying things like api: https://someapi.com/path/?q=title and then a template that loads the API data via getJSON/getCSV. There is a new command that IIRC is named getRemote, but I can’t find it right now.
So the process of getting API data is done on creation of the website, not creation of the content. If you require an API request to create your content (like you create a new post about blafasel and the content of that post should be fetched from an API) then create a shell script or npm script that asks the API for content, then runs hugo new and then fills in the content. But that is stuff for a new thread
Thanks @davidsneighbour for such a detailed response. it is really helpful.
I hope in future there will be more focus on remote data get at page creation time instead of current single option to fetch at build time
since Hugo have:
Layouts which can be applied to a page in front matter
Page with front matter can be created using archetype
And finally Hugo can get content from remote url
There must be a way to reverse the last step and populate the markdown file from remote content
The current option of resources.GetRemote is great if only there was a way to use this feature at the level of Hugo new page that would be great. ( I don’t know if my requirement make sense, if it does apologies in advance)
Hugo new creates a page is there an option to rebuild existing page using a different archetype or at least refresh using an updated previously applied archetype.
Well, as I was trying to imply: Hugo is a static WEBSITE generator, not a static CONTENT creator. Do your content from outside Hugo and all is well. The “egg-laying wool-milk-pig” is not part of Hugo.
+++
title = '{{ replace .Name "-" " " | title }}'
date = {{ .Date }}
draft = false
+++
{{ with data.GetJSON (os.Getenv "HUGO_REMOTE_URL") }}
{{ .body }}
{{ end }}
command
HUGO_REMOTE_URL="https://api.github.com/repos/gohugoio/hugo/releases/tags/v0.92.0" hugo new hugo-release-notes/v0.92.0.md
The resulting page is static. If the remote data changes and you rebuild the site, the page will not change.
If you want the page to get the current remote data when you rebuild the site, store the env value in a page param, and use a shortcode to retrieve the data.
archetypes/hugo-release-notes.md
+++
title = '{{ replace .Name "-" " " | title }}'
date = {{ .Date }}
draft = false
remote_url = "{{ os.Getenv "HUGO_REMOTE_URL" }}"
+++
{{< shortcode-that-retrieves-data >}}
This works because the shortcode is not evaluated when creating the page with hugo new.