0 / 0
Skip to content

Learning VitePress and Integrating with Obsidian

As I’ve been building this blog with VitePress, I’ve discovered many powerful features that make it an excellent platform for publishing content. At the same time, I’ve been using Obsidian as my personal knowledge management system. In this post, I’ll share my experiences combining these two powerful tools.

Why VitePress?

VitePress is a static site generator powered by Vue and Vite. It’s designed to be lightweight and fast, making it perfect for documentation sites and blogs. Here are some of the features I’ve come to appreciate:

  1. Markdown-centered: VitePress uses Markdown as its primary content format, which makes writing content straightforward and portable.

  2. Vue-powered: The ability to use Vue components within Markdown files gives incredible flexibility.

  3. Fast development experience: Thanks to Vite, the development server is lightning fast with hot module replacement.

  4. Simple configuration: The configuration is straightforward and well-documented.

  5. Themeable: The default theme is clean and modern, but it’s also highly customizable.

My VitePress Journey So Far

Setting up VitePress was relatively straightforward. After installing the dependencies, I was able to start creating content right away. However, I quickly realized I wanted to customize several aspects:

Blog Structure

I organized my blog posts in a dedicated directory and created a data loader to process them. This allowed me to:

  • Extract frontmatter metadata
  • Generate slugs automatically
  • Sort posts by date
  • Filter posts based on tags

Date Handling

One challenge I faced was handling dates consistently. I implemented a utility function using dayjs that:

  • Validates date inputs
  • Falls back to file creation dates when necessary
  • Formats dates consistently across the site
  • Handles timezone issues properly

Theme Customization

I’ve made several customizations to the default theme:

  • Added a responsive favicon that changes color based on light/dark mode
  • Customized the navigation bar with the site logo
  • Improved the blog post listing with better metadata display

Deploying to Cloudflare Pages

One of the most exciting parts of my VitePress journey has been deploying the site to Cloudflare Pages. This process was surprisingly straightforward and offers several advantages:

  1. Automatic Deployments: By connecting my GitHub repository to Cloudflare Pages, every push to the main branch triggers a new build and deployment.

  2. Preview Deployments: Pull requests automatically get their own preview deployments, making it easy to review changes before merging.

  3. Custom Domain: Setting up my custom domain with HTTPS was just a few clicks away.

  4. Global CDN: Cloudflare’s global CDN ensures my blog loads quickly for visitors worldwide.

The deployment process involved:

  1. Creating a Cloudflare Pages project and connecting it to my GitHub repository
  2. Configuring the build settings:
    • Build command: npm run docs:build
    • Build output directory: docs/.vitepress/dist
  3. Setting environment variables (if needed)
  4. Configuring my custom domain and DNS settings

The entire setup took less than 15 minutes, and now my deployment workflow is completely automated. When I push changes to my repository, Cloudflare Pages builds and deploys the updated site automatically.

Integrating with Obsidian

Obsidian is a powerful knowledge management application that stores notes as local Markdown files. This makes it a perfect companion to VitePress. Here’s how I’m integrating the two:

Shared Content Structure

Both Obsidian and VitePress work with Markdown files, which makes content sharing possible. I’ve structured my Obsidian vault to align with my blog’s content organization:

  • Using consistent frontmatter across both systems
  • Organizing content with similar folder structures
  • Using tags consistently for categorization

Publishing Workflow

My current workflow for publishing content from Obsidian to my VitePress blog involves:

  1. Draft in Obsidian: I start by drafting content in Obsidian, taking advantage of its linking and visualization features.

  2. Add Frontmatter: I ensure each note has the necessary frontmatter (title, description, date, tags).

  3. Export to VitePress: When a note is ready to publish, I copy it to my VitePress src directory.

  4. Review and Publish: I review the content in the VitePress development environment before building and deploying.

  5. Git Push and Auto-Deploy: Once I’m satisfied, I commit and push the changes, which triggers the Cloudflare Pages deployment.

Challenges and Solutions

Integrating these two systems hasn’t been without challenges:

Handling Obsidian-Specific Syntax

Obsidian uses some custom Markdown syntax that doesn’t work in VitePress:

  • Internal Links: Obsidian’s [[wiki-links]] need to be converted to standard Markdown links.
  • Embeds: Obsidian’s ![[embed]] syntax needs to be replaced with standard image or content includes.
  • Callouts: Obsidian’s callout blocks need custom styling in VitePress.

I’m working on a pre-processing script that handles these conversions automatically.

Image Management

Managing images between the two systems has been tricky:

  • Obsidian typically stores images in an attachments folder
  • VitePress needs images in the public directory or relative to the content

My solution involves a consistent naming convention and a script to sync images between the two systems.

Maintaining Bidirectional Updates

When I update content in one system, I want those changes reflected in the other. I’m exploring:

  • Git-based synchronization
  • File system watchers
  • Custom scripts to detect and propagate changes

Future Improvements

As I continue this journey, I’m planning several improvements:

  1. Automated Sync: Create a more robust synchronization system between Obsidian and VitePress.

  2. Better Metadata Handling: Improve how metadata is shared and updated between systems.

  3. Custom Components: Develop Vue components that replicate Obsidian’s visualization features.

  4. Publishing Workflow: Streamline the process of selecting and publishing content from my personal knowledge base.

  5. CI/CD Enhancements: Add automated testing and quality checks to my Cloudflare Pages deployment pipeline.

Conclusion

Combining VitePress and Obsidian has created a powerful system for both personal knowledge management and public sharing. VitePress provides an excellent platform for publishing polished content, while Obsidian offers superior tools for connecting ideas and managing personal knowledge. Cloudflare Pages completes the picture by providing effortless deployment and global content delivery.

The journey hasn’t been without challenges, but the benefits of having a seamless flow between my personal notes and public blog make it worthwhile. I’m excited to continue refining this system and sharing what I learn along the way.

If you’re using either of these tools, I’d love to hear about your experiences and any tips you might have for better integration!


What tools do you use for knowledge management and publishing? Have you tried connecting different systems? Share your thoughts in the comments below.