Patching Beautifulhugo to Work with Hugo 0.57

Fixing the theme to keep up with the spec changes in the Hugo upgrade

With the Hugo version upgrade it looks like some variable formats will stop working from now on, so I made the theme handle them. In Beautifulhugo they are not handled in versions from before May, so this may end up being only a temporary fix. Environment Hugo 0.57 Beautifulhugo :handled from 2019-05-08 onwards (the information below is from before 2019−05-08) Edited files layouts/_default/list.html layouts/index.html layouts/partials/footer.html layouts/partials/head.html Changes Before After {{ .Hugo.Generator }} {{ hugo.Generator }} {{ .RSSLink }} {{ with .OutputFormats.Get “RSS” }}{{ . RelPermalink }}{{ end }} {{ .Hugo.Version }} {{ .Site.Hugo.Version }} {{ .URL }} {{ .Permalink }}, {{ .RelPermalink }} .Data.Pages .Site.RegularPages Edited sections layouts/_default/list.html Copy @@ -47,12 +47,12 @@ <ul class="pager main-pager"> {{ if .Paginator.HasPrev }} <li class="previous"> - <a href="{{ .URL }}page/{{ .Paginator.Prev.PageNumber }}/">&larr; {{ i18n "newerPosts" }}</a> + <a href="{{ .Permalink }}page/{{ .Paginator.Prev.PageNumber }}/">&larr; {{ i18n "newerPosts" }}</a> </li> {{ end }} {{ if .Paginator.HasNext }} <li class="next"> - <a href="{{ .URL }}page/{{ .Paginator.Next.PageNumber }}/">{{ i18n "olderPosts" }} &rarr;</a> + <a href="{{ .Permalink }}page/{{ .Paginator.Next.PageNumber }}/">{{ i18n "olderPosts" }} &rarr;</a> </li> {{ end }} </ul> layouts/index.html Copy @@ -9,7 +9,7 @@ {{ end }} <div class="posts-list"> - {{ $pag := .Paginate (where .Data.Pages "Type" "post") }} + {{ $pag := .Paginate (where .Site.RegularPages "Type" "post") }} {{ range $pag.Pages }} <article class="post-preview"> <a href="{{ .Permalink }}"> @@ -49,12 +49,12 @@ <ul class="pager main-pager"> {{ if .Paginator.HasPrev }} <li class="previous"> - <a href="{{ .URL }}page/{{ .Paginator.Prev.PageNumber }}/">&larr; {{ i18n "newerPosts" }}</a> + <a href="{{ .Permalink }}page/{{ .Paginator.Prev.PageNumber }}/">&larr; {{ i18n "newerPosts" }}</a> </li> {{ end }} {{ if .Paginator.HasNext }} <li class="next"> - <a href="{{ .URL }}page/{{ .Paginator.Next.PageNumber }}/">{{ i18n "olderPosts" }} &rarr;</a> + <a href="{{ .Permalink }}page/{{ .Paginator.Next.PageNumber }}/">{{ i18n "olderPosts" }} &rarr;</a> </li> {{ end }} </ul> layouts/partials/footer.html Copy @@ -17,10 +17,8 @@ {{ end }} {{ if .Site.Params.rss }} <li> - {{ if .RSSLink }} - <a href="{{ .RSSLink }}" title="RSS"> - {{ else }} - <a href="{{ .Site.RSSLink }}" title="RSS"> + {{ with .OutputFormats.Get "RSS" }} + <a href='{{ .RelPermalink }}' title='RSS'> {{ end }} layouts/partials/head.html Copy @@ -61,7 +61,7 @@ <meta property="og:type" content="website" /> <meta property="og:site_name" content="{{ .Site.Title }}" /> <!-- Hugo Version number --> - {{ .Hugo.Generator -}} + {{ hugo.Generator -}} References: [Read More]

How to Delete a File Whose Name Starts with -- (Hyphens)

How to remove things like --filename

While I was working with Hugo, either because I got an argument wrong or because I built in View mode, a directory named “–bind=192.168.1.1” ended up being created What does not work When you try to delete a file or directory that starts with – (hyphens) like this, commands such as the ones below cannot remove it Copy $ rm --bind=192.168.1.1 # naturally this is mistaken for an argument, so ☓ $ rm ”--bind=192.168.1.1” ☓ $ rm '--bind=192.168.1.1' ☓ The correct way to delete it You insert “–” (two hyphens) into the command arguments and then specify the file or directory [Read More]

Installing Ripgrep on Mac, CentOS and Debian

Installing ripgrep

Notes from installing Ripgrep(rg), which searches faster than grep, ack and silver_searcher, on several platforms Mac Install it straight from homebrew (if homebrew is already installed) Copy $ brew install ripgrep CentOS 7 On CentOS, ripgrep is not in the standard repositories or in epel, so install it as follows Copy $ sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo $ sudo yum install ripgrep Debian 10 Copy # apt install ripgrep If your version of Debian9 or Ubuntu is old and the package is not in apt, use the following [Read More]

Upgrading Debian 9 Stretch to Debian 10 Buster

Major and minor upgrade steps from Debian 9 to Debian 10

Debian Upgrade A major upgrade from Debian 9.x to 10.x Upgrade procedure Checking the version Copy $ cat /etc/debian_version 9.1 Updating Copy # apt-get update # apt-get upgrade # apt-get dist-upgrade Rewriting sources.list Copy # sed -i 's/stretch/buster/g' /etc/apt/sources.list Running the upgrade Copy # apt-get update # apt-get upgrade If any NFS-related daemons are running, stop them Copy # systemctl stop rpcbind The final upgrade [Read More]

Show Invisible Characters in Vim

Show whitespace and tabs while editing in Vim

Once you get used to Python layout and Markdown, there are times you want Vim to visualize blank lines and tabs.

Show them temporarily in Vim

: set list
: set listchars=tab-,trail:-,eol:↲,extends,precedes,nbsp:%,space:_

Show them permanently

Add the following to ~/.vimrc

set list
set listchars=tab-,trail:-,eol:↲,extends,precedes,nbsp:%,space:_

Turn the display back off

Inside Vim,

:set nolist

Reference

[Changing listchars colors for tabs, spaces, newlines, and so on in Vim (in Japanese)] (https://qiita.com/pollenjp/items/459a08a2cc59485fa08b )

ItemDescription
set listShow invisible characters
set listcharsConfigure which characters to use
tabShow tab characters
trailShow trailing spaces
eolShow newlines
spaceShow spaces
Vim 

Things to Decide First When You Start a Hugo Site

Items worth deciding before you build a site with Hugo

A note to myself on the items I want to decide first in Hugo Choosing a theme The way front matter and shortcodes are written differs from theme to theme, and layout and CSS matter too, so I want to take my time at the start and settle on a theme that is easy to customize Hugo Themes: Complete List Since a Hugo version upgrade can turn some syntax invalid, it may be better to pick a theme that is updated frequently My personal recommendations would be Academic, Tranquilpeak, Learn and Beautifulhugo [Read More]

How to Make Hugo Output .html URLs with uglyURLs

How do you make the site output .html?

The output format of a site differs from theme to theme, but when you write an article called content, the output format is normally something like the following. Copy https://your-site/post/content/ https://your-site/content/ When you want to make this your-site/content.html, that is, end it in .html Add the following inside config.toml Copy uglyURLs = true Note: If “url:xxxx” is written in the front matter of an article, it takes precedence, so uglyURLS has no effect and you do not get the html format. If it is written, only that article gets output as something like your-site/xxxx/ [Read More]

How to Write Tables in Markdown

Basic table creation with Markdown

Table notation in Markdown Basically all you do is separate things with | Basic form Copy |Header 1|Header 2|Header 3| |-------|-------|-------| |Item 1|Item 2|Item 3| Header 1 Header 2 Header 3 Item 1 Item 2 Item 3 The first row is the header The header always seems to end up bold The second row is the separator that sets the attributes Any number of - seems to be fine, but four or more is probably better From the third row onwards, you just keep adding as many items and contents as you like Alignment When you want the headers and items left aligned, right aligned or centred [Read More]

wp-tegaki Plugin Error on WordPress

Disabled wp-tegaki still throws a PHP parse error

Does the wp-tegaki plugin error even when it is disabled?

On a WordPress blog, the following error appeared even though the wp-tegaki plugin I used to run was already disabled. (wp-tegaki is no longer maintained and does not support PHP 7.x)

PHP Parse error:  syntax error, unexpected 'new' (T_NEW) in /var/www/html//wp-content/plugins/wp-tegaki/wp-tegaki-img.php on line 24

I was not using it anyway and it was annoying, so I deleted it.

These days it is better to use web fonts anyway.

Preventing Copy and Paste of Posts in Beautifulhugo

Applying copy-and-paste protection

Preventing copy and paste of posts

Referring to “テキストのドラッグ、画像のコピーを禁止して、記事をコピーさせない方法 ” (in Japanese), I disable text selection (dragging)

Note that this is applied for the Beautifulhugo theme, so adapt it as appropriate for other themes.

Adding the script

Add this inside the body tag

  • beautifulhugo/layouts/_default/baseof.html
<body onMouseDown="return false;" onSelectStart="return false">

Fixing the CSS

Add this to the css for body

  • beautifulhugo/static/css/main.css
user-select:none;
-webkit-user-select:none;
-ms-user-select: none;
-moz-user-select:none;
-khtml-user-select:none;
-webkit-user-drag:none;
-khtml-user-drag:none;

The point

In short, all you need to do is write the Javascript inside the body tag and apply the CSS to body in the CSS