How can I run "exampleSite" of a theme imported as a Hugo module?

I have imported a theme in hugo.toml:

baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'

[module]
    [[module.imports]]
        path = "github.com/blankoworld/hugo_theme_adam_eve"
        disable = false

How can I run it’s exampleSite folder located on GitHub, without adding it as a Git submodule or downloading a copy locally into the themes/ directory.

I have tried running:

hugo server --source "github.com/blankoworld/hugo_theme_adam_eve/exampleSite/"

but it doesn’t work.

I’m looking for a way to source the exampleSite/ located on a remote repository.

Is this what you are looking for?

git clone https://github.com/blankoworld/hugo_theme_adam_eve.git
cd hugo_theme_adam_eve/exampleSite/
hugo server --themesDir ../..

Or if you want to start from scratch:

hugo new site my-project
cd my-project
hugo mod init my-project
hugo mod get github.com/blankoworld/hugo_theme_adam_eve

Then add the [[module.imports]] setting you mentioned already to your hugo.toml and run:

hugo server

Does this get you started?

I’m aware of

git clone https://github.com/blankoworld/hugo_theme_adam_eve.git
cd hugo_theme_adam_eve/exampleSite/
hugo server --themesDir ../..

but want to avoid cloning, because its easier to change the theme in hugo.toml through module imports than git clone.

I did the following:

hugo new site my-project
cd my-project
hugo mod init my-project
hugo mod get github.com/blankoworld/hugo_theme_adam_eve

Then added [[module.imports]] to hugo.toml, and finally hugo server -D.

This doesn’t run the exampleSite folder located on the theme’s GitHub.

Does this get you started?

It gets me started with an empty content folder, not the theme’s exampleSite.

Hugo looks for content in /content. So, it might perhaps help to copy content and static of exampleSite to your project root.

Would something like hugo server --source REMOTE_REPO/exampleSite work ?

You mean --source https://something/...? Seriously? You want to download all the stuff from a remote location every single time hugo builds your source? What for?

You mean --source https://something/...? Seriously? You want to download all the stuff from a remote location every single time hugo builds your source? What for?

I’m not going to build stuff from the remote location every single time. This is to evaluate and switch themes - all I have to do is comment out [[module.imports]] in hugo.toml. This is better than cloning multiple themes and running their exampleSite locally.

It might be convenient (I haven’t given this much thought) if we vendored an “exampleSite” directory if present. Then you could do:

hugo mod vendor
hugo server -s _vendor/github.com/blankoworld/hugo_theme_adam_eve/exampleSite --theme ../..

Currently the “exampleSite” is not vendored, but you can find it in your cache. Something like:

~/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/blankoworld/hugo_theme_adam_eve@v0.0.0-20221104230834-48436eef467b/exampleSite

But I think lack of permissions on the cache would prevent you from doing:

hugo server -s ~/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/blankoworld/hugo_theme_adam_eve@v0.0.0-20221104230834-48436eef467b/exampleSite --theme ../..

Which is probably a good thing because… yuck.

1 Like

That makes sense !