So …

Hi back i guess ? :)

Years have passed, the previous engine setup proved unreliable, update to jekyll, ruby, and whatever keep breaking up the thing in all ways i could not even think of.

Jekyll-assets particularly seem to have a pretty hard time keeping up with the ecosystem, so … let’s try another way ?

Hugo

I found this tool, Hugo ages ago, basically the same concept as jekyll but based on a go software, always wanted to do the switch hopefully it would prove more reliable ?

And there is even an import tool !

# hugo import jekyll blog blog-hugo
Importing...
Congratulations! 18 post(s) imported!
Now, start Hugo by yourself:
$ git clone https://github.com/spf13/herring-cove.git blog-hugo/themes/herring-cove
$ cd blog-hugo
$ hugo server --theme=herring-cove

Noice ! Continuing:

$ git clone https://github.com/spf13/herring-cove.git blog-hugo/themes/herring-cove
Cloning into blog-hugo/'themes/herring-cove'...
remote: Enumerating objects: 178, done.
remote: Total 178 (delta 0), reused 0 (delta 0), pack-reused 178
Receiving objects: 100% (178/178), 6.57 MiB | 12.31 MiB/s, done.
Resolving deltas: 100% (71/71), done.
$ cd blog-hugo 
$ hugo server --theme=herring-cove
port 1313 already in use, attempting to use an available port
Start building sites … 
hugo v0.96.0+extended linux/amd64 BuildDate=unknown VendorInfo=debian:0.96.0-1
ERROR 2022/05/12 00:24:01 render of "page" failed: execute of template failed: template: partials/header.html:8:10: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/05/12 00:24:01 render of "page" failed: execute of template failed: template: partials/header.html:8:10: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/05/12 00:24:01 render of "page" failed: execute of template failed: template: partials/header.html:8:10: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/05/12 00:24:01 render of "page" failed: execute of template failed: template: partials/header.html:8:10: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/05/12 00:24:01 render of "page" failed: execute of template failed: template: partials/header.html:8:10: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
Error: Error building site: failed to render pages: render of "home" failed: "/home/benoit/perso/site/blog-hugo/themes/herring-cove/layouts/index.html:9:17": execute of template failed: template: index.html:9:17: executing "index.html" at <.RSSLink>: can't evaluate field RSSLink in type *hugolib.pageState
Built in 19 ms

Oookay, so as it turms out, the ‘herring-cove’ suggested default theme is actualy not compatible with recents hugo, some deprecated variables are still in use like ‘.Hugo’ and ‘.RSSLinks’

$ git clone https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
$ hugo server --theme=ananke
Start building sites … 
hugo v0.96.0+extended linux/amd64 BuildDate=unknown VendorInfo=debian:0.96.0-1+b1

                   | EN  
-------------------+-----
  Pages            | 64  
  Paginator pages  |  2  
  Non-page files   |  0  
  Static files     | 12  
  Processed images |  0  
  Aliases          |  2  
  Sitemaps         |  1  
  Cleaned          |  0  

Built in 142 ms
Watching for changes in /home/benoit/perso/site/blog-hugo/{archetypes,assets,content,data,static,themes}
Watching for config changes in /home/benoit/perso/site/blog-hugo/config.toml, /home/benoit/perso/site/blog-hugo/themes/ananke/config.yaml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Much better !

Converting Post Meta tags

While hugo and jekyll use basically the same way to describe a post meta (title, date, tags, ..) and most of the difference is usually being taken care thru the import tool, there is actually two modifications that often need to be taken care of:

  • categories and tags must be defined as a list using angled brackets ("[]")
  • categories and tags value must often be enclosed in quotes.
---
categories: ["blog"]
tags: [ "hugo" ] 
...
---

Actually jekyll categories are probably best replaced by hugo main ‘section’ taxonomy so this part can even be removed.

Converting syntax highlighting

The conversion should be taken care of by the hugo import process, however a simple sed line could always take care of it later if needed:

sed -i 's/{% highlight \(.*\) %}/\{\{< highlight \1 >}}/;s/{% endhighlight %}/\{\{< \/ highlight >}}/' *.md *.markdow

Layout

So that’s all good and all but the layout i was using previously doesn’t exist in Hugo (being abandonned and all even in jekyll anyway) so i ventured into re-creating something similar but in the same time less “huge”.

Availables themes are huge chunk of code, i tried customizing the ananke theme initialy but ended up removing everything and going from scratch.

The previous theme was using bootstrap & jquery, resulting in almost 80KB of css+js, i’m currently at 5KB of css and no js, but there is no mobile view for now, still i have some margin ;).

Look like however that while github widget is relatively efficient (less than 4KB) & twitter links are quite costly, adding 155KB to the download, more than half of the whole page.

Still some work to do here but that’ll do for now.

Content fixes

For now i haven’t found any major rendering issue on the markdown, most of the syntax changes are taken care of by the import tool, except the cross post linking.

Thankfully i had only one, and the change is pretty straigthforward, going from [FreeBSD Setup]({% post_url 2017-02-14-freebsd-setup %}) to [FreeBSD Setup](/blog/2017/02/14/freebsd-setup/).

Conclusion

Hugo has evolved rapidly in the last years, my initial conversion attempt weren’t this straightforward, and i am quite happy of the result. The layout could benefit from using the config field in some places and all but this should be fine for first publication … only one month after initial work !