Tools: Almost Ready to Write

Tools: Almost Ready to Write

Source: Dev.to

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. Start by deleting skeleton posts that were added with the theme. 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. We need to run with the --unsafe flag; otherwise, it gives an error: Update archetypes to use YAML front matter in the site and theme; example below. Add our first section. I will call it Devlog and here I will write my blog development journey. Add section's front matter to theme/content/devlog/_index.md Cleanup site/content/_index.md which contains content for the home page. We are ready to write and ready to publish. Comment in "consistency: hugo new site uses config.toml, but YAML for content" issue ↩ Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse COMMAND_BLOCK:
$ git rm -r theme/content/posts
$ git add -u
$ git commit -m 'delete skeleton posts' COMMAND_BLOCK:
$ git rm -r theme/content/posts
$ git add -u
$ git commit -m 'delete skeleton posts' COMMAND_BLOCK:
$ cd site/
$ hugo convert toYAML --unsafe
$ cd .. COMMAND_BLOCK:
$ cd site/
$ hugo convert toYAML --unsafe
$ cd .. CODE_BLOCK:
ERROR command error: Unsafe operation not allowed, use --unsafe or set a different output path CODE_BLOCK:
ERROR command error: Unsafe operation not allowed, use --unsafe or set a different output path CODE_BLOCK:
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
+--- CODE_BLOCK:
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
+--- COMMAND_BLOCK:
$ mkdir theme/content/devlog
$ touch theme/content/devlog/_index.md COMMAND_BLOCK:
$ mkdir theme/content/devlog
$ touch theme/content/devlog/_index.md CODE_BLOCK:
---
title: "Devlog"
--- CODE_BLOCK:
---
title: "Devlog"
--- CODE_BLOCK:
diff --git a/theme/hugo.toml b/theme/hugo.toml
index 5c26950..dccaed7 100644
--- a/theme/hugo.toml
+++ b/theme/hugo.toml
@@ -9,8 +9,8 @@ title = 'My New Hugo Site' weight = 10 [[menus.main]]
- name = 'Posts'
- pageRef = '/posts'
+ name = 'Devlog'
+ pageRef = '/devlog' weight = 20 [[menus.main]] CODE_BLOCK:
diff --git a/theme/hugo.toml b/theme/hugo.toml
index 5c26950..dccaed7 100644
--- a/theme/hugo.toml
+++ b/theme/hugo.toml
@@ -9,8 +9,8 @@ title = 'My New Hugo Site' weight = 10 [[menus.main]]
- name = 'Posts'
- pageRef = '/posts'
+ name = 'Devlog'
+ pageRef = '/devlog' weight = 20 [[menus.main]] - 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'
- 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
- 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
+---
- Add our first section. I will call it Devlog and here I will write my blog development journey. $ mkdir theme/content/devlog
$ touch theme/content/devlog/_index.md Add section's front matter to theme/content/devlog/_index.md ---
title: "Devlog"
--- And show it in menu diff --git a/theme/hugo.toml b/theme/hugo.toml
index 5c26950..dccaed7 100644
--- a/theme/hugo.toml
+++ b/theme/hugo.toml
@@ -9,8 +9,8 @@ title = 'My New Hugo Site' weight = 10 [[menus.main]]
- name = 'Posts'
- pageRef = '/posts'
+ name = 'Devlog'
+ pageRef = '/devlog' weight = 20 [[menus.main]]
- Final touch. Cleanup site/content/_index.md which contains content for the home page.
- We are ready to write and ready to publish. - Comment in "consistency: hugo new site uses config.toml, but YAML for content" issue ↩