This is a simple, fast, and customizable static blog generator written in Python. It reads Markdown posts with optional metadata, converts them into static HTML pages using Jinja2 templates, and deploys the site to GitHub Pages automatically via GitHub Actions.
π sajjadtalks.github.io/blog
π¦ your-blog-repo/ ββ .github/workflows/build-site.yml # GitHub Actions workflow ββ README.md # This file ββ blog/ # Your markdown posts β ββ Hello-World.md β ββ Python-Markdown.md ββ generate.py # Blog generator script ββ requirements.txt # Python dependencies ββ static/ # Static assets (JS, CSS) β ββ script.js β ββ style.css ββ templates/ # HTML templates β ββ base.html β ββ index.html β ββ post.html ββ docs/ # Output folder (auto-generated) git clone https://github.com/sajjadtalks/blog.git cd blogPut your Markdown files inside the blog/ folder. Example:
--- title: Hello World date: 2024-01-01 11:20:00 summary: This is my first post! --- # Welcome to My Blog This is the content of my first blog post.Each post supports YAML frontmatter with fields like title, date, and summary.
Use Python 3.11+ and run:
pip install -r requirements.txtpython generate.pyThe generated HTML site will be saved in the docs/ folder.
You can serve the site locally to preview it:
cd docs python -m http.serverOpen http://localhost:8000 in your browser.
This project uses a GitHub Actions workflow to automatically build and deploy your blog to the gh-pages branch whenever you:
- Push to the
mainbranch - Modify any file in
blog/,templates/,static/,generate.py,requirements.txt, or the workflow file itself
- On Push: The GitHub Action runs
generate.pyto build the site intodocs/ - Deploy: Uses peaceiris/actions-gh-pages to push the built site to
gh-pages - GitHub Pages: Serves your static site from the
gh-pagesbranch
Make sure to:
- Go to your repoβs Settings β Pages
- Set:
- Source:
gh-pagesbranch - Folder:
/ (root)
- Source:
- π Supports pagination (10 posts per page)
- π Sorts posts by date (newest first)
- π§ Builds a
search_index.jsonfile for custom search - π¨ Styled with custom
style.cssand supportscodehilite - β
Automatically creates
.nojekyllfor proper GitHub Pages support - π Supports Markdown extensions like tables, task lists, code blocks
- Python 3.11+
- See
requirements.txtfor packages like:markdownjinja2python-frontmatterpymdown-extensions
--- title: My First Blog Post date: 2025-04-15 11:20:00 summary: This post talks about Python static site generators. --- # Hello Static Blogging! Here is **some content** with `code`. ``` python print("Hello World")``` You do not need to manually push to gh-pages. Just push your Markdown or template changes to main, and the deployment is automatic π
MIT License β Free to use and modify.
Created with β€οΈ by @sajjadtalks