Blog

Almost Ready to Write

We have the site, we have the theme, and according to the quickstart guide, we are ready to add content. But in actuality, not quite yet.

  1. Start by deleting skeleton posts that were added with the theme.

    $ git rm -r theme/content/posts
    $ git add -u
    $ git commit -m 'delete skeleton posts'
    
  2. Default Hugo site and theme skeletons use TOML front matter, but I prefer using YAML, mainly because GitHub does not support TOML and JSON rendering in front matter1.

    Hugo has a handy tool to automatically convert between front matter styles.

    $ cd site/
    $ hugo convert toYAML --unsafe
    $ cd ..
    

    We need to run with the --unsafe flag; otherwise, it gives an error:

    ERROR command error: Unsafe operation not allowed, use --unsafe or set a different output path
    
  3. Update archetypes to use YAML front matter in the site and theme; example below.

    diff --git a/theme/archetypes/default.md b/theme/archetypes/default.md
    index 25b6752..c84c25b 100644
    --- a/theme/archetypes/default.md
    +++ b/theme/archetypes/default.md
    @@ -1,5 +1,5 @@
    -+++
    -date = '{{ .Date }}'
    -draft = true
    -title = '{{ replace .File.ContentBaseName "-" " " | title }}'
    -+++
    +---
    +title: "{{ replace .File.ContentBaseName `-` ` ` | title }}"
    +date: "{{ .Date }}"
    +draft: true
    +---
    
  4. Add our first section.

    I will call it Devlog and here I will write my blog development journey.

  5. Final touch.

    Cleanup site/content/_index.md which contains content for the home page.

  6. We are ready to write and ready to publish.


  1. Comment in “consistency: hugo new site uses config.toml, but YAML for content” issue ↩︎

Tags: