[SOLVED] Create a new theme in the current working directory

The docs on the hugo new theme command say

Create a new theme (skeleton) called [name] in the current directory.

When I run hugo new theme [name], it creates a themes/ directory in the current directory, then inside themes/ is my newly generated theme [name].

I understand (and like) the idea here of being in the root of your site when running this command, and it generating those directories/files for you.

But is there is way to run this command and it create my theme [name] in the current working directory (as the docs mention)?

I tried running hugo new theme --help but didn’t see any relevant options.

If this isn’t currently possible, all good. I’ll just copy/paste the theme where I want it.
(The theme will be in its own directory, outside of my site directory).

Don’t think you would want it to create that directory inside your project root directory since the ./themes has special significance for Hugo w/r/t the lookup order (i.e. you need to create your themes there). Why would you want this to create theme directories at the root? If I had to guess, is this because you like the scaffolding that’s provided by creating a new theme?

Sorry, didn’t explain myself well enough.

So my plan was to have my theme repo in its own directory, that way it’s not dependent on whatever site it happened to be created under.

Then I would check it out as a git submodule into whatever site I was testing it against.

For example, if I’m currently in C:\Projects and I run hugo new theme my-theme, I want the theme to be created at:

C:\Projects\my-theme

Ahhhh, gotcha. And hugo new site <your-site-name> isn’t enough, right? I guess you want the theme.toml and the LICENSE and all the handy scaffolding of files and directories, right?

Hmmm…it would be a bit hackish, but you could just treat one level up from ..\Projects like it’s the root of the project, add a config.toml and set themesDir = "Projects" and see if that works (admittedly not tested), but I guess that would still mean you’re not running hugo new theme from inside \Projects since you’re up one level. Sorry brother, I’m at a loss on this one… :frowning:

Correct.

No worries though. My current “manual” way is working just fine.

Thanks for taking the time to respond :+1:

1 Like