smhk

Upgrading Node, Go and Hugo for this website

Time for some routine maintenance. Need to upgrade the dependencies for this website and fix any resulting issues.

Switch from NVM for Windows to fnm §

To manage Node, I had been using NVM for Windows. However, that appears to no longer be recommended. Instead, fnm seems to be officially endorsed as the default installed for Node on Windows. And fnm can be installed using Scoop, which I already use for managing packages on Windows.

So the steps are (using PowerShell):

  1. Install Scoop.

  2. Install fnm using Scoop:

    $ scoop install fnm
    
  3. Configure fnm to be accessible from PowerShell:

    $ # Open profile
    $ notepad $profile
    $ # NOTE: If that failed, run this to create the file, then retry:
    $ # new-item $profile -itemtype file -force
    
  4. In the Notepad window, paste this and then save:

    fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
    
  5. Re-open the PowerShell window.

  6. Install fnm and Node v20.18.0 and npm v10.8.2:

    $ fnm use --install-if-missing 20
    $ node -v # should print `v20.18.0`
    $ npm -v # should print `10.8.2`
    

Done. It should now be possible to use fnm from within PowerShell.

Note that fnm will automatically read any .nvmrc file in the current directory, and offer to install that Node version if it does not already exist.

Uprading Node §

Upgraded from Node v18.8.0 to v20.18.0.

Did so by doing fnm use --install-if-missing 20, and then updating .nvmrc to contain v20.18.0.

Upgrading Go §

Upgraded from Go v1.20.5 to v1.23.2.

Did so by installing Go v1.23.2 from the website, then updating GO_VERSION in hugo.toml to GO_VERSION = "1.23.2".

Upgrading Hugo §

Upgraded from Hugo v0.115.1 to v0.136.2.

Did so by installing Hugo via Scoop:

$ scoop install hugo-extended

Then updating HUGO_VERSION in hugo.toml to HUGO_VERSION = "0.136.2".

Fixed some deprecation warnings and errors.

Pagination §

Got the warning:

deprecated: site config key paginate was deprecated in Hugo v0.128.0 and will be removed in a future release. Use pagination.pagerSize instead

Fixed by changing

hugo.toml
Paginate = 1000

To:

hugo.toml
[languages]
  [languages.en]
    # ...
      [languages.en.pagination]
        pagerSize = 1000

Use of .Site.IsServer within a Go module §

Started getting this error:

ERROR deprecated: .Site.IsServer was deprecated in Hugo v0.120.0 and will be removed in Hugo 0.137.0. Use hugo.IsServer instead.

Searched codebase for .Site.IsServer and found nothing. Suspected that the problem lay with some third-party code. The only possible suspect is the plausible-hugo Go module.

Initially tried to upgrade plausible-hugo:

$ go get -u
go: no package to get in current directory

That failed.

Tried listing all Go modules:

go list -u -m all
github.com/divinerites/plausible-hugo v1.17.2 [v1.20.0]

That succeeded.

Tried to update plausible-hugo specifically:

$ go get -u github.com/divinerites/plausible-hugo
go: downloading github.com/divinerites/plausible-hugo v1.20.0
go: upgraded github.com/divinerites/plausible-hugo v1.17.2 => v1.20.0

That succeeded.

Though in hindsight, perhaps I should have used hugo mod get -u?