Publishing an English Version of a Hugo Blog at a Separate /en/ URL

Publishing an English Version of a Japanese Blog at a Separate URL with Hugo's Multilingual Support

I had come to want my Japanese-language tech blog to be readable from the English-speaking world too. An easy way to do this is to run Google’s translation widget on the page and switch to an English display at the same URL. On another site that had been enough. This time, though, the goal was not “convenience for visitors already here” but discovery and indexing from English queries. I judged that a widget could not satisfy that. [Read More]

Getting GA4 Working on Hugo with Beautifulhugo and Mainroad

Migrating Google Analytics to GA4

Migrating a site built with Hugo to GA4 In my environment I use the Beautifulhugo and Mainroad themes, so the customization here is limited to those Also, this assumes the GA4 code for Google Analytics has already been obtained, so I will skip the explanation of Google Analytics itself Beautifulhugo Copy head.html into the root folder and edit it Copy $ pwd /hugo $ cp themes/beautifulhugo/layouts/partials/head.html layouts/partials/. head.html (changed lines only) Copy - {{ template "_internal/google_analytics_async.html" . }} + {{- partial "analytics" . -}} Create /layouts/partials/analytics.html with the following content Copy {{ if not .Site.IsServer }} {{ with .Site.GoogleAnalytics }} <!-- Global site tag (gtag.js) - Google Analytics 4--> <script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', '{{ . }}'); </script> {{ end }} {{ end }} Write the GA4 code into config.toml (changed lines only) Copy googleAnalytics = "G-XXXXXXXXXX" Mainroad In the mainroad theme at the time of writing, analytics is loaded in layout/_default/baseof.html, and looking at the code below it seems as though GA4 is already supported [Read More]

Sending Mail Through Gmail's SMTP Server with msmtp

How to Configure Gmail SMTP in msmtp

I want to install msmtp on Debian10 and send mail through Gmail’s SMTP server msmtp On hosts that only send mail I used to use sSMTP a lot, but on Debian10 there is no ssmtp package. The replacement for it is msmtp Installing msmtp Copy # apt install msmtp msmtp-mta Configuration There is no configuration file in /etc, so copy the sample Copy # cp /usr/share/doc/msmtp/examples/msmtprc-system.example /etc/msmtprc Incidentally, for a per-user configuration it is [Read More]