Integrate Plausible as Hugo module

Hello,

I’m trying to integrate plausible on my Hugo site using the theme component / hugo module from Divinerites.

I want to install this as a Hugo module, which is the reccommended method according to the readme.

I’m having some issues getting modules to work, which I assume might be do to the fact that I don’t fully understand how they work. I’ve read the documentation here and also checked out some articles such as the one by the New Dynamic. (Sorry had to remove the link as it appears new users are limited to max 2 links per post.)

Some information regarding how I use Hugo:

  • Develop locally on my MacBook (using Hugo extended)
  • Push changes to GitHub
  • Deploy from GitHub to Netlify

Steps I’ve taken so far:

  1. Initialized my site as a Hugo module with hugo mod init GitHub Name/GitHub Project

  2. Installed Go, git through Homebrew. Everything is up-to-date.

  3. Used hugo mod get -u to get the Plausible module from GitHub. It seems this step was successful, as hugo created both go.mod and go.sum files.

  4. Updated the config.toml with the relevant entries:

[module]
    [[module.imports]]
        path = "github.com/divinerites/plausible-hugo"
        disabled = false
        [[module.import.mounts]]
            source = 'github.com/divinerites/plausible-hugo/layouts/partials'
            target = 'layouts/partials'
    [[module.mounts]]
        source = 'content'
        target = 'content'
    [[module.mounts]]
        source = 'static'
        target = 'static'
    [[module.mounts]]
        source = 'layouts'
        target = 'layouts'
    [[module.mounts]]
        source = 'data'
        target = 'data'
    [[module.mounts]]
        source = 'assets'
        target = 'assets'
    [[module.mounts]]
        source = 'i18n'
        target = 'i18n'
    [[module.mounts]]
        source = 'archetypes'
        target = 'archetypes'

What I don’t understand:

  1. Where are the files for module? Mounting through config.toml didn’t seem to work.

  2. What happens when I update the module through the command line? Do the local files get overwritten?

  3. Is installing modules this way compatible with deploying through Netlify?

I’d appreciate any help or guidance you can provide.

Hello , Why are you adding this lines in the plausible-hugo def section ?

I never wrote that on my documentation. It should work as expected without it.

Yes works like a charm.

Hi Divinerites,

First of all, thank you for the great plugin/module.

I got desperate at one point and tried all sorts of different methods I found in the different articles I was reading. That’s why those configuration lines are in there.

I used the other methd to install it now and it’s working perfectly. Also, now that I’ve installed it I understand that I actually don’t need to modify the files. All the variables are managed through the config.toml

I’m going to re-install it as a module tomorrow. Let’s see if I can get it to work.

Thanks for taking the time to reply!!

No worries. And don’t hesitate to ask.

Yes all is managed thru config.toml options.

And installing it as a module make the update so easy (thanks to hugo modules)

Pro tip : you can star it on gihub if you like it :slight_smile:

[EDIT] : I’ve updated the documentation with a working example as a module

1 Like