HUGO

Bulma packaged as a Hugo Module

Bulma packaged as a Hugo Module (Hugo Modules).

Usage

config/_default/config.yaml

module:
  imports:
    - path: github.com/peaceiris/hugo-mod-bulma

assets/bulma.scss

@import "mod/bulma/utilities/_all.sass";
@import "mod/bulma/base/_all.sass";

In a Hugo template file.

<head>
  <style>
    {{ $bulmaCSS := resources.Get "bulma.scss" | toCSS | minify }}
    {{ $bulmaCSS.Content | safeCSS }}
  </style>
</head>
5 Likes

Why mod/bulma instead of bulma? I am trying to learn, not critizise :wink: Bulma is quite known to not be a double title for some probably different module?

And second question (still learning about modules): How does the module or/and Hugo know that there is a new version out? Do you have to version that in your repo or will it “come through” somehow?

Thank you for the question, I am learning the Hugo Modules too. ʕ◔ϖ◔ʔ

Why mod/bulma instead of bulma ? I am trying to learn, not critizise :wink: Bulma is quite known to not be a double title for some probably different module?

I am importing multiple Hugo Modules in my blog project. To indicate that CSS or JavaScript libraries are managed as Hugo Modules, I defined mod/bulma instead of bulma. I plan to publish another my Hugo module with this setting, too.

And second question (still learning about modules): How does the module or/and Hugo know that there is a new version out? Do you have to version that in your repo or will it “come through” somehow?

First of all, I was trying to import the Bulma directly and pin a specific version as follows.

hugo mod get github.com/jgthms/bulma@0.9.1
# config/_default/config.yaml
module:
  imports:
    - path: github.com/jgthms/bulma
      mounts:
        source: sass
        target: assets/mod/bulma

With this method, the go.mod and go.sum does not have a human-readable tag name (like 0.9.1) due to the Bulma is not initialized as a Go (Hugo) module.

go.mod

module github.com/peaceiris/peaceiris.com

go 1.15

require github.com/jgthms/bulma v0.0.0-20200929200348-dc2f9bb5f331 // indirect

go.sum

github.com/jgthms/bulma v0.0.0-20200929200348-dc2f9bb5f331 h1:veJtgl3T4I9jsS2PQ0jik1xtGQ54UL6HgJbkoV4wBsc=
github.com/jgthms/bulma v0.0.0-20200929200348-dc2f9bb5f331/go.mod h1:89FLBKXYFKfOKAoDeUT26V0pHGwzr205cMXAEqtAVOI=

Therefore, I have published peaceiris/hugo-mod-bulma to manage versions of Bulma with human-readable tag names.

go.mod of my blog project is here.

module github.com/peaceiris/peaceiris.com

go 1.13

require (
    github.com/peaceiris/hugo-mod-bulma v0.1.0 // indirect
    github.com/peaceiris/hugo-theme-iris v0.21.1 // indirect
)

We can know which version of Bulma peaceiris/hugo-mod-bulma@v0.1.0 contains at the Release hugo-mod-bulma v0.1.0 · peaceiris/hugo-mod-bulma page.

For upgrading, just run hugo mod get -u.

$ hugo mod get -u                                     
go: github.com/peaceiris/hugo-mod-bulma upgrade => v0.1.1
go: downloading github.com/peaceiris/hugo-mod-bulma v0.1.1
2 Likes