Hugo

Unexpected usefulness of offline blogging with Hugo

Life in changing. Internet evolve and become available everywhere.. suddenly, we are more and more offline.

When you have cable connection and expect to be online only in the office or at home - you are always online, always with good (or at least the same) speed. Then, mobile internet shine and at first it had affected only content reading, but not content creation.

But now, lifestyle itself changed and people become more mobile. More and more professions become remote. That lead to more travel. And more travel lead to more time offline. Quite often: unexpectedly offline. But you still have to do your remote work in time.

Right now I’m writing this post from airport. I don’t have local sim yet, and airport wifi disconnects every hour.

With Hugo I stll can work with my website. Local server let me check everything, I can fix elder posts, can work around SEO, can write new.

What can I do with oldschool CMS which require me to be online and with stable connection? Only teke some notes to copy-paste them into CMS and edit their look later. And even copy-paste can be harmful for website layout, as for lot’s of CMS themes do not provide html validation and rely on WYSIWYG editors.

My flight was rescheduled twice and so back in Wordpress days I will lose 27 hours of working time. That’s a lot!

A bit of everyday hugo commands

I’m using Hugo as blog engine. So, here is a bit of cli commands

Create new post

hugo new post/postname.md

Formatting in summary

By default summary is plain text, soo.. just use <!--mоre--> and formatting will work in summary. I’m going to make most of posts just only summary, maybe I can change hugo code, to add <!--mоre--> automatically?

Lets try..

Yes, I can change archetypes/default.md. And I also want draft to be false by default.. here we go:

---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: false
---

<!--mоre-->

Btw: I used Cyrillic ‘o’ in ‘more’, otherwise it breaks layout. Maybe there is better solution, but I do not think I will need to talk about <!--mоre--> again any time soon.

Publish post

  • Go to post header section (top of .md file)
  • Remove draft: true or replace it with draft:false

Run locally

hugo server -D

Will run hugo server in “development” mode, draft blogs are visible

hugo server

will run it in “release” mode

Deploy

  • We need 2 repositories: – One is our root repository with themes and all raw data – Subproject liked to %blogname%.github.io
  • So git add %ssh.link.to.blogname.project.on.github% public
  • hugo command will compile static html content to public folder
  • cd public && git add . && git commit -m 'whatever' && git push

Also: README.md has a priority over index.html, so, remove it if you had added it during project creation.