Almost Ready to Write
Source: Dev.to
Delete skeleton posts
git rm -r theme/content/posts
git add -u
git commit -m 'delete skeleton posts'
Convert front matter to YAML
The default Hugo site and theme skeletons use TOML front matter, but YAML is often preferred (e.g., for better GitHub rendering).
cd site/
hugo convert toYAML --unsafe
cd ..
Note: The
--unsafeflag is required; otherwise Hugo returns:ERROR command error: Unsafe operation not allowed, use --unsafe or set a different output path
Update archetypes to use YAML front matter
--- 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 the first section (Devlog)
Create the section folder and index file:
mkdir theme/content/devlog
touch theme/content/devlog/_index.md
Add front matter to theme/content/devlog/_index.md:
---
title: "Devlog"
---
Show it in the menu
Update theme/hugo.toml to replace the default “Posts” menu entry with “Devlog”:
--- 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
Clean up site/content/_index.md, which contains the home page content.
You are now ready to write and publish your Hugo site.