These scripts help to convert Markdown notes into the hugo compatibile sites. I created these scripts for converting my notes (format below) into hugo-theme-learn pages.
- hugo installed
- empty hugo site with optional hugo-theme-learn theme
- markdown notes in format:
---
tags:["some/nested/tag", "tag"]
---
# Note title
some text here
If you don't have with YAML at the beginning, then you can use my other project to create it (with initial tags)
WARNING Script overwrites all changes in OUT* directories and it may even delete some files (OUT_ASSETS), so you should point it to directories used only by it.
- Copy deploy.sh to root directory of your hugo site
- Edit script if needed
- Run it
Run python script, check -h
for help, but generally:
python3 markdown2hugo.py <NOTES_DIRECTORY> <HUGO_SITE_CONTENT_DIR> <HUGO_SITE_STATIC_DIR>
Python script is designed for notes directory:
├── forensics
│ ├── note1.md
│ ├── note2.md
│ └── note3.md
├── reversing
├── random.py
└── note2.md
└─ .note2.assets
└── somepic.png
...
Notes can be collected into filetree-based categories, this structure is preserved in the output posts.
Script looks for only markdown notes and directories (with the full content) with .assets
extension, other files are ignored. In above example random.py
won't be copied.
Finally script looks for 1st #
(h1 tag) and uses it's content as page title, so below note:
---
tags:["some/nested/tag", "tag"]
---
# Note title
some text here
![pic](./note.assets/mypic.png)
Will be converted into:
---
tags:["some/nested/tag", "tag"]
title: "Note title"
---
# Note title
some text here
![pic](/img/note.assets/mypic.png)
I also included optional archetype files a bit more usable than default ones used by hugo-learn theme. To install them just put them into <hugo_site_root>/archetypes/
(remove "archetypes-" prefix from names).