This is a simple guide to use Obsidian to draft and publish your Jekyll blog posts.
I’ve been using Obsidian for note taking and journaling for a couple of years now. I figured that since Jekyll uses markdown for it’s pages, might as well use Obsidian to draft the posts as well.
To setup the workflow, I used Obsidian native ‘Template’ plugin. Steps to setup the workflow is as follows:
Steps1 : Create a folder within Obsidian where you will create drafts of posts. Let’s call this folder ‘Blog Drafts’
Step 2: Create a template file within your template folder and name it ‘template-blog’.
- If you are new to the ‘templates’ plug-in, read through this guide from obsidian
- Add the template note properties with the following fields:
Property Fields Name | Property Field Type | Property Field Value |
---|---|---|
title | Text | {{title}} |
date | Date | {{date}} {{time}} |
tags | Tags | |
categories | List |
Step 3: Set a hotkey to ‘Insert Template’ if not already done. Read through this guide from obsidian for more details.
Step 4: Create and save a bash script to the root of your local Jekyll folder. Remember to change mode to allow execution. Run the script to sync the obsidian ‘Blog Drafts’ folder with the _drafts’ folder in Jekyll. If you are like me, you might also want to auto-publish the draft and serve it for local view. Sample script as follows:
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
#Copy draft posts from obsidian into jekyll _drafts folder
rsync -vhr /mnt/d/Laptop-Data/ActiveData/Obsdidan/Personal\ Notes/1.Projects/Content\ Creation/nwrzd.github.io/ ./_drafts/ --delete
#Publish all drafts as posts
jekyll publish ./_drafts/* -f
#Serve the jekyll site locally
jekyll serve
Fin! The workflow setup is now complete.
To create a draft blog post:
- Create a new file within ‘Blog Drafts’ folder in Obsidian.
- Apply ‘template-blog’ as template using the hotkey.
- Write your article/blog entry.
- Update the tag and category fields.
- Execute the sync script. The newly created draft along with any other drafts will be synced into the _drafts folder.
- If you are ready to publish, use Jekyll’s workflow to publish the post (if you did not automate publish within the script).
- Check out your new post on Jekyll.
That’s it.
This is the initial iteration of the workflow. Will share updates as it happens.