This repository contains a Go program that allows converting and copying contents from a custom Obsidian directory to Hugo-compatible content. Obsidian is a note-taking app that utilizes Markdown as its file format. Hugo, on the other hand, is a static site generator that allows creating websites from Markdown content.
Go to file
Óscar M. Lage 6a56a2f9f2 Feat: Add support for 'build: true' tag in frontmatter
This feature allows triggering the execution of the `build_action` command specified in
the `.ini` file when adding `build: true` to the frontmatter of the modified file. Upon
detecting this tag, the specified command will be executed automatically, facilitating
the automation of build processes in response to specific file modifications
2024-04-10 12:02:42 +02:00
README.md Feat: Add support for 'build: true' tag in frontmatter 2024-04-10 12:02:42 +02:00
go.mod Initial commit 2024-04-09 20:06:34 +02:00
go.sum Initial commit 2024-04-09 20:06:34 +02:00
main.go Feat: Add support for 'build: true' tag in frontmatter 2024-04-10 12:02:42 +02:00
obs2hugo.ini.sample Feat: Add support for 'build: true' tag in frontmatter 2024-04-10 12:02:42 +02:00

README.md

obs2hugo

This repository contains a Go program that allows converting and copying contents from a custom Obsidian directory to Hugo-compatible content. Obsidian is a note-taking app that utilizes Markdown as its file format. Hugo, on the other hand, is a static site generator that allows creating websites from Markdown content.

Key Features

  • Content Conversion: The program converts Markdown files from the Obsidian directory to Hugo-compatible Markdown files.
  • Image Copying: It copies the images included in Markdown files to a specific directory within Hugo's directory structure.
  • Configuration File Generation: It creates additional configuration files necessary for Hugo to correctly process the content.

Configure

Configuration runs in ~/.config/obs2hugo/obs2hugo.ini or ~/.config/obs2hugo.ini, something like this:

watcher_dirs = /Users/johndoe/vaults/obsidian/microposts-hugo:/Users/johndoe/vaults/obsidian/posts-hugo
hugo_dirs = /Users/johndoe/code/hugo/src/content/posts:/Users/johndoe/code/hugo/src/content/microposts
build_action = hugo build

Note: The watcher_dirs and hugo_dirs variables must have the same number of elements, taking into account that : acts as a separator. They are correlated so the first element in watcher_dirs corresponds to the first element in hugo_dirs, the second element in watcher_dirs corresponds to the second element in hugo_dirs, and so forth.

Usage

  1. Clone the repository to your local machine.
  2. Run the program providing the path to the Obsidian directory and the destination directory for Hugo.
  3. The program will convert Markdown files, copy images, and generate necessary configuration files.
$ go run main.go

If you add build: true in the frontmatter of the file you are modifying, it will force the execution of the build_action command specified in the .ini file.

Requirements

  • Go installed on your system.
  • Have a Hugo project set up and ready to receive content.
  • Have an Obsidian vault on your system.

Contribution

Contributions are welcome! If you find bugs or wish to improve the program, feel free to open an issue or submit a pull request.