How to avoid Hugo Modules?

There’s no automatic way to convert a Hugo module to a static ZIP variant in the themes folder.

In fact a Hugo module is still just a theme, no need to remove the go.mod or anything.

As you can see in your Gallery example it can be also installed as git submodule. And a git submodule is more or less just a tracked way of using git clone.

  • Module (after go installation and hugo mod init)

    [module]
      [[module.imports]]
        path = "github.com/nicokaiser/hugo-theme-gallery/v4"
    
  • use as a submodule

    git submodule add --depth=1 https://github.com/nicokaiser/hugo-theme-gallery.git themes/gallery
    
    theme = 'gallery'
    
  • use as git clone

    git clone --depth=1 https://github.com/nicokaiser/hugo-theme-gallery.git themes/gallery
    
    theme = 'gallery'
    
  • most repos allow downloading a zip and some provide a release zip, just download

Options:

  • so manually recursive replacing the import with theme + downloading to respective themes/folder should do the trick (versioning?).

  • another way would be to create a site importing all modules and then use mod vendor to physically place the module inside the site. and then pack that thing no Go or git needed after. see in related posts of your one. Go Modules vs git submodule? - #6


off topic, don’t wan’t to start a discussion about
looks like you have a very special look on these “modularization” topics … In fact Hugo’s Modules don’t import Go modules. Theme Modules are just theme components. It’s a quite save way to modularize a theme.

your argumentation remembers me of the ancient days where we discussed about .so and .dll, ruby gems or git submodules, …

2 Likes