A Python utility that converts Markdown files to HTML and generates complete blog sites from GitHub repositories.
- Convert individual Markdown files to styled HTML
- Clone GitHub repositories and generate complete blog sites
- Automatically finds and converts blogs in
/blogsdirectory - Handles both published and unpublished blogs
- Generates home page with blog preview cards and images
- Extracts metadata (title, date, author, tags) from YAML frontmatter
- Centralized image management with duplicate handling
- Google Analytics integration with per-repository tracking
- Responsive design with proper heading and paragraph spacing
- HTML to Markdown conversion utility
-
Clone this repository:
git clone https://github.com/yourusername/blogstack.git cd blogstack/blog_generator -
Install the required dependencies:
pip install -r requirements.txt
python md_to_html.py input.md
python md_to_html.py input.md output.html
python md_to_html.py --repo https://github.com/username/blog-repo.git
This will:
- Clone the repository
- Look for a
blogs/directory - Convert all
.mdfiles to HTML with frontmatter processing - Copy and organize images to centralized
/images/directory - Generate home page with blog preview cards
- Organize blogs by status (published/draft)
- Create the site in
../dist/repo-name/directory
python html_to_md.py
Converts HTML files in kaons/ directory to Markdown files in output/ directory with:
- YAML frontmatter generation
- Image directory copying
- Current date metadata
Your blog repository should have this structure:
your-repo/
├── blogs/
│ ├── 2024/
│ │ ├── my-first-post.md
│ │ └── another-post.md
│ ├── unpublished/
│ │ └── draft-post.md
│ └── tech/
│ └── python-tips.md
Add YAML frontmatter to your Markdown files:
---
title: My Blog Post Title
date: 2024-01-15
author: Your Name
status: published
tags: [tech, tutorial]
---
Your blog content here...Create analytics.conf file with repository-to-tracking-ID mapping:
MindWorks=G-XXXXXXXXX
my-blog-repo=G-XXXXXXXXXX
The system will automatically add Google Analytics tracking to all pages based on the repository name.
- Python 3.6+
- Git (for repository cloning)
- Dependencies listed in
requirements.txt:- markdown>=3.4.0
- PyYAML>=6.0
- GitPython>=3.1.0
- beautifulsoup4>=4.9.0
blogstack/
├── blog_generator/
│ ├── md_to_html.py # Main blog generator
│ ├── html_to_md.py # HTML to Markdown converter
│ ├── blog_post.template # Blog post HTML template
│ ├── blog_home.template # Home page HTML template
│ ├── analytics.template # Google Analytics script template
│ ├── analytics.conf # GA tracking ID configuration
│ └── requirements.txt # Python dependencies
└── output/ # Generated sites and converted files