Hugo new bash tab-completion

I am wondering if I am using tab-completion in bash correctly for the ‘hugo new’ command or if there is something I am missing.

I make new content via, e.g:
hugo new content posts/my-first-post/

I get tab-completion to work until new and content, but not for ‘posts’ (or any other directory under the content/ folder).

I wonder if this is expected behavior and if not completing the directories (sections) under content is intentional.

Ideally I would like to be able to do something like this:
hugo new content posts/second-post/

And have Hugo automatically create the file, either inferred by the last forward-slash, or perhaps even via archetypes.

But just tab-completion for the folders under the content dir would be nice.
I’m not sure if I am missing something, or if everyone just writes out the complete section names without tab-completion.

Like any other command (e.g., cp, mv, etc.), the path passed to the hugo new command must be relative to the working directory in order for path auto-completion to work.

hugo new content content/posts/my-first-post/
hugo new content content/posts/

If you want to create leaf bundles without having to type “”…

├── posts/
│   └──
hugo new content content/posts/my-third-post


1 Like

Thanks a bunch jmooring.
That makes perfect sense. And I feel dumb that I expected it to work without the first ‘content/’ part relative to the working dir.
(Maybe nudged in this direction because ‘hugo new content’ works without explicitly providing the content/ directory).

In any case, I now have (and an images/ subfolder) configured for my archetype.

1 Like

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