The static Folder Convention
Where Flask looks for assets by default.
The static Folder Convention is a free Flask Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Flask Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Assets Need a Home
Your app needs CSS, JavaScript, and images. Flask gives them one default home: a folder named static next to your app. 📁
Where Flask Looks
By convention, Flask serves anything inside the static folder automatically, so you never write a route to hand out a stylesheet yourself.
The Folder Layout
Place static right beside your app.py file. Flask finds it relative to your application package without any extra setup.
myapp/
app.py
static/
style.css
templates/The Public URL Prefix
Files in that folder are reachable under the /static URL prefix. A file named style.css becomes available at /static/style.css in the browser.
Organize with Subfolders
You can nest folders inside static to stay tidy. The path on disk simply maps to the path in the URL, one to one.
static/
css/style.css
js/app.js
img/logo.pngURL Mirrors the Path
So static/css/style.css is served at /static/css/style.css. The browser path mirrors your folder structure exactly. 🔗
It Is Just a Default
The name static is a default, not a law. Flask uses it unless you tell it otherwise, which keeps every project predictable.
Rename the Folder if Needed
Pass static_folder when you create the app to point Flask at a differently named directory on disk.
from flask import Flask
app = Flask(__name__, static_folder="assets")Change the URL Prefix Too
You can also change the public prefix with static_url_path, so assets appear under /files instead of /static.
app = Flask(__name__, static_url_path="/files")Static Means Unchanging
These files are static because Flask sends them as-is, with no Python running. That is exactly why serving them is so fast.
Templates Are Different
Do not put HTML you render into static. Dynamic pages belong in templates, while static holds only finished, ready-to-send assets.
Quick Check
You drop logo.png into the static folder. Where can the browser reach it?
Recap: The static Folder
You learned the static convention: drop assets in that folder and Flask serves them under /static, fast and free. Next, link them cleanly. ✨
Frequently asked questions
Is the “The static Folder Convention” lesson free?
Yes — the full text of “The static Folder Convention” is free to read here on the web, and the Flask Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Flask Academy course, upgrade to CoddyKit PRO.
What will I learn in “The static Folder Convention”?
Where Flask looks for assets by default. You practise Flask Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Flask Academy?
No prior experience is required. Flask Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The static Folder Convention” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Flask Academy lesson?
Yes. Every Flask Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The static Folder Convention
- Link Assets with url_for static
- Cache Busting with File Versions
- Static Files in Production Reality