Skip to main content leehalls.net

Emacs,orgmode,hugo + Ox-Hugo

OK so i dont pretend to be an all knowing computer geek in fact just the opposite i’m aging computer enthusiast that grew up in the golden age of electronics and computers but i do have some understanding from starting out with BBC’s,Spectrums and hacking high score tables or re-programming the header so the game could run from microdrive instead of C90 tape :wink: through to TCL for aero engine data analysis and then python for a home monitoring system but my decision to start afresh, move to a new domain and use hugo + ox-hugo has had me reaching for a glass of the strong stuff and several relaxing hours getting my arse handed to me on COD!

You may ask Why if you use orgmode already did you struggle with ox-hugo? well despite all the excellent documentation provided by Kaushal and following the example of Ken Grimes it just didnt twig, for me something was missing.

I normally keep one blog post per org file, each one saved with the date as the filename eg 20200508.org but wanted to try and jump to the ox-hugo preferred one file to rule all method because with a file per post i sometimes struggled to link between them and i wanted to use more of orgmode’s features. So i tried to take an old post and tweak it, i refactored the tags and categories added export features and jumped right in, needless to say it didnt work.

What i was doing was thinking the top heading was for each post ie

text code snippet start

* post 1                                                         :@emacs:org:
:PROPERTIES:
:export_file_name: post1
:export_description: my big dumbass
:END:
 now onto the rest blah blah

* post 2
:PROPERTIES:
:export_file_name: post2
:export_description: my big dumbass
:END:
 now onto the rest blah blah

text code snippet end

It was not until i found Shane Sveller’s site that the lights switched on, he has a really clear explanation and what did it for me a full proper example page. Definitely worth visiting his site for full details but in brief i should have been doing something like this;

text code snippet start


* Posts
:PROPERTIES:
:EXPORT_HUGO_SECTION: posts
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :noauthor true :nocomment true :nopaging true :noread true
:END:

** starting afresh
:PROPERTIES:
:export_file_name:
:export_description:
:END:

text code snippet end

So each blog or post is a subheading of the main and the same goes for pages bloody easy really. OK in my limited defense i was also trying to apply a theme to the posts and getting lost there with trying to tweak the output at the time as well as trying to understand how to “ox-hugo”. For example;

A TODO in a post is output by ox-hugo in markdown as;

markdown code snippet start

# <span class="org-todo done DONE">DONE</span> automatically rebuild my orgmode & sync to my phone {#automatically-rebuild-my-orgmode-and-sync-to-my-phone}

markdown code snippet end

every single theme i tried converts this into MASSIVE text in old HTML terms <H1> or bigger ie

i spent a lot of time trying different themes just to see if they did something different then i tried to edit the CSS files and i know nothing about CSS

After all this i can recommend if you do not want to learn about css, layouts and other hugo terms i’d probably walk away from hugo but if you’re already an orgmode user and want a challenge, want the full org experience for your site then pull up a comfy chair, grab a drink and stick on some meditation music and be prepared but you may find the following reading material useful before you start: