How to Set Up Your Own Blog Using Python and Flask
I’m using MacOS, but other operating systems are similar—just adjust commands as needed.
Step 1: Set Up Your Environment
It’s best to use a Python Virtual Environment so that your project dependencies are isolated. This prevents conflicts with other projects.
Commands:
Install Python (latest version I use is 3.11)
brew install [email protected]
Check Python version
python3.11 --version
Create a project folder and navigate into it
mkdir blog && cd blog
Create a virtual environment
python3.11 -m venv venv
Activate the virtual environment
source venv/bin/activate
You should see (venv) in your terminal prompt
Upgrade pip (Python package manager)
pip install --upgrade pip
Install required packages
pip install -r requirements.txt
Deactivate the virtual environment when done
deactivate
Tip: Always activate the virtual environment before working on your project to make sure dependencies are installed locally.
Step 2: Set Up Your Project Structure
A clear directory structure keeps your project organized. For a simple blog, your project should look like this:
blog/
├── venv/ # Virtual environment
├── app.py # Main Python file using Flask
├── templates/ # HTML templates
│ └── index.html # Basic web page structure
└── static/ # Static files like CSS
└── style.css # Styling for your blog
If any of these folders or files don’t exist, create them.
Step 3: Start Coding
Not everyone codes from scratch these days. Tools like ChatGPT (OpenAI) can help you learn the basics and even write code snippets.
You can find examples of a complete blog setup here:
https://github.com/mal-22/my-block
Tip: Experiment and modify the code to understand how it works.
Step 4: Use GitHub to Save Your Work
GitHub is a great tool for beginners and professional developers alike. For this project, we’ll use it to store our code safely.
Create a GitHub account if you don’t have one.
Create a new repository for your blog (public or private).
Install Git locally (inside or outside your virtual environment):
brew install git
git --version
Common Git commands:
git status # Check current changes
git add . # Stage all changes
git commit -m "Initial commit" # Save changes locally
git push # Upload to GitHub
Run commands one by one and ask AI for help if you encounter errors. Once successful, all your code will be safely on GitHub.
Step 5: Run Your Blog on a Free Server
There are many free hosting options. I recommend:
Render.com
– Free hosting for small projects.
Supabase.com
– Free database for storing your blog posts.
Follow their setup instructions, deploy your project, and you’ll have a live blog accessible online!
Congratulations!
You now have a functioning blog with Python, Flask, GitHub, and free hosting. Keep experimenting and improving it.