How I Copy my Obsidian Files into my git Repository
A workflow for automatically copying, processing, and publishing Obsidian notes to a git repository with metadata and image handling
1 minute read
My workflow for frequently publishing content to my personal website with Obsidian relies on constantly fetching files from my Obsidian vault into my git repo and pushing it straight to GitHub, triggering a Vercel deployment.
How It Works
I have a yarn script called cpAndPush that I run from the command line:
yarn cpAndPush
cpAndPush looks like this:
yarn prebuild:cpFiles && git add . && git commit -m 'update content' && git push origin HEAD
For this script to work, there are a few notes about my workflow:
- I work on
mainfor my personal website, so doing this publishes to curiouslychase.com - I keep my local repo clean if I'm not actively working on something. If I need to run this and have development changes, I'll run
git stash save -u -k "wip"before runningyarn cpAndPushso that my working tree is clean
yarn prebuild:cpFiles runs a script that:
- Recursively scans my Obsidian vault for
.mdand.mdxfiles - Filters files by
status: publishedorstatus: draftin frontmatter - Excludes files with
fileClass: course-material - Routes files to different directories based on
fileClass:fileClass: stack→content/stacks/fileClass: prompt→content/prompts/- Default →
content/posts/
- Processes metadata:
- Generates
slugfrom filename usingslugify - Sets
pubDatefromliveDateor file creation time - Sets
updatedDatefrommodified,pubDate, or file modification time - Sets
typebased onfileClass(stack, prompt, or article)
- Generates
- Extracts and copies embedded images:
- Finds
![[image.png]]syntax - Copies images from vault's
01 - Meta/03 - Media/topublic/img/notes/ - Also handles
coverfrontmatter field for cover images
- Finds
First Cohort
No Coding Experience Required
Build Your Website with AI—No Code Required
Learn to create and deploy professional websites using ChatGPT and Claude. Go from complete beginner to confident website builder.
