Chase AdamsChase Adams
AboutContentPromptsPlaygroundNewsletter

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 main for 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 running yarn cpAndPush so that my working tree is clean

yarn prebuild:cpFiles runs a script that:

  • Recursively scans my Obsidian vault for .md and .mdx files
  • Filters files by status: published or status: draft in 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 slug from filename using slugify
    • Sets pubDate from liveDate or file creation time
    • Sets updatedDate from modified, pubDate, or file modification time
    • Sets type based on fileClass (stack, prompt, or article)
  • Extracts and copies embedded images:
    • Finds ![[image.png]] syntax
    • Copies images from vault's 01 - Meta/03 - Media/ to public/img/notes/
    • Also handles cover frontmatter field for cover images
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.

Start Building Today

Post Details

Published
Oct 22, 2022
Category
Productivity
Share
Ask ChatGPT
Ask Claude

Similar Posts

Running Claude Agents in Parallel with Git Worktrees

Running Claude Agents in Parallel with Git Worktrees

in git, workflow

Use git worktrees to run multiple Claude agents on separate features without conflicts

AboutAI Workflow SpecContentStacksNewsletterPromptsRSS