Creating Aliases with Hugo Commands

So, is it not possible to create an alias with an added argument at the end of it?

Here is the alias I’m trying to create:

alias hpost="hugo new content/blog/" I need to add a “space” and add article name.md after the alias.

It doesn’t execute correctly when I try it. Can anyone help? Also, yes, I’m in the right folder when running the command.

This is the error I get “Error: failed to resolve “content/blog/” to a archetype template”

that’s more bash than hugo :slightly_smiling_face:

hpost() {                                                                                                 INT ✘ ╱ 3.10.6  ╱ 13:02:05
  hugo new post/$1
}
$ hpost2 cenas.md
Content "/Users/brunoamaral/Labs/gregory-ms-website/content/post/cenas.md" created

Thank you! That worked!

I should have explained a bit.

Think of an alias as a text shortcut, it gets expanded. What I wrote is a function, it can receive input, in this case $1 .

1 Like

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