Hugo Modules

Today I spent some more time modifying the IndieFeed theme

As I mentioned earlier, I started using hugo modules instead of git submodule from the beginning. One of the downside of it was I could not preview my changes without pushing the changes to github first.

Sometimes that might be OK, most times it is not.

How do theme developers work in such scenario. Turns out there is a hack just for that.

So much so that documentation mention for Local development at multiple places 😄

The directive is replace. Read the documentation here

I did this in go.mod of this project. But hugo server kept complaining that go.mod was missing from my local folder where I work on the theme. (It is not under themes folder of this project)

Turns out I need to do the following in my theme directory.

hugo mod init github.com/mandarvaze/indiefeed which created go.mod there. Now hugo server had no complaints ✌️

I also removed theme entry from my config.yaml

-theme: ["github.com/mandarvaze/indiefeed"]
+
+module:
+  imports:
+  - path: github.com/mandarvaze/indiefeed
+

These steps documented here and here respectively.