Home β€Ί Curriculum β€Ί Build a Portfolio & GitHub Profile
Updated for Python 3.12+ Β· November 2026

πŸ—ƒοΈ Build a Portfolio & GitHub Profile
in Python

Build a Python portfolio on GitHub: choose projects, write a README, learn git basics, .gitignore, licences, project structure, GitHub Pages and good commit habits.

Beginner 7 lessonsβ‰ˆ 41 min read by Glenn Pansensoy

What this lesson is about

A portfolio is evidence of what you can do. Anyone can write that they know Python; a repository that anyone can open, read, install and run shows it. For a learner, a freelancer or someone changing field, a handful of well-presented projects on GitHub is the most direct way to let other people judge your work for themselves instead of taking your word for it.

Most of what makes a repository look finished is not clever code. It is a clear README, a sensible folder layout, a .gitignore so no junk is committed, a licence, commit messages a stranger can follow and a short explanation of why you made the choices you did. These are habits, and every one of them can be learned in an afternoon and applied to each project you build.

This lesson walks through choosing projects, structuring the README, the git commands you need day to day, ignoring files, picking a licence, laying out a project, publishing with GitHub Pages and a profile README, keeping tidy commits and writing about decisions. The runnable examples are small tools you can use on your own work: a README checklist scorer, a commit message validator built with re, and a project-structure printer. I make no promises about jobs or outcomes; the goal is to make your work easy to understand and easy to trust. For project ideas, see project ideas.

What you will learn

  • βœ“Choose a small set of projects that show different skills
  • βœ“Structure a README so a visitor understands the project in a minute
  • βœ“Use the everyday git commands: init, status, add, commit, branch, push
  • βœ“Write a correct .gitignore and keep secrets out of history
  • βœ“Choose a licence and understand what having none means
  • βœ“Lay out a Python project with source, tests and configuration
  • βœ“Publish a page with GitHub Pages and write a profile README
  • βœ“Write consistent commit messages and short notes about your decisions

Why programmers should learn this

  • β˜…Reviewers rarely have time to read all your code, so a clear README and tidy history let them judge the work quickly and fairly.
  • β˜…Version control is a daily tool in almost every software team; practising it on your own projects is practice for real collaboration.
  • β˜…A project with tests, a licence and setup instructions shows you finish things, which is often more telling than how big the project is.
  • β˜…Writing down why you chose a design makes you think harder about it and gives you something concrete to discuss when anyone asks about your work.
  • β˜…Good habits such as ignoring secrets and keeping commits small prevent real mistakes, like publishing an API key by accident.

Choosing what goes in your portfolio

Three to five projects that are finished and explained beat twenty abandoned experiments. I choose projects to show different things: one that handles data from input to output, one that talks to an outside service or file format, one with a user interface or command-line interface, and one with real tests. A tutorial clone is fine for learning, but for the portfolio pick problems you adapted or invented so the decisions are yours.

Scope matters more than ambition. A tool that does one job well, has instructions anyone can follow and handles bad input gracefully shows more skill than a half-working large idea. If you need inspiration, project ideas lists many starting points that you can shrink to a weekend size.

Pin your best repositories on your GitHub profile, archive or delete the ones you would not want a stranger to read, and make sure the code in each repository really runs from a fresh clone. Test that last point yourself in a new folder and virtual environment; it is the commonest way a good project looks broken.

A selection grid to fill inrun on your computer
Project        Shows            Input -> Output           Tests?  README done?
-------------  ---------------  ------------------------  ------  ------------
expense-cli    CLI, files       CSV -> summary report     yes     yes
weather-bot    HTTP, JSON       API -> daily message      some    yes
note-search    text, sqlite     notes -> search results   yes     no

Line by line

  1. 1-2Column headings: what the project demonstrates and what flows in and out of it.
  2. 3-5Fill one row per project. A blank 'Tests?' or 'README done?' tells you what to improve before you share it.
πŸ’‘

Finish and polish before you start the next project. A short list of complete work is a stronger signal than a long list of unfinished repositories.

A README that explains your project in a minute

The README is the front page of your repository, written in Markdown. A visitor decides within seconds whether to keep reading, so lead with what the project does in one or two sentences, then show it: a screenshot, a short output sample or a usage example. Only after that come installation steps, configuration, how to run the tests and a short note on what you would do next.

I use a consistent order: title and one-line summary, a demo or example, features, installation, usage, how it works or design notes, tests, licence. Each installation instruction should be copy-pasteable and tested on a clean machine. State the Python version and list the dependencies in requirements.txt or pyproject.toml so the reader does not have to guess.

Be honest about limits. A section titled 'Known limitations' makes you look careful, not weak, and it prevents a reader from misusing the project. Avoid claims you cannot show, such as 'fast' or 'production ready', and prefer a measurable statement: what input it accepts, what it outputs, how it was tested.

README skeleton (Markdown)run on your computer
# expense-cli

Summarise a CSV of expenses by category from the command line.

## Demo

    $ python -m expense_cli data/sample.csv
    food       123.40
    transport   45.00

## Features
- Reads CSV files with date, category and amount columns
- Prints totals per category, largest first

## Installation
    python -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt

## Usage
    python -m expense_cli path/to/file.csv

## How it works
Short notes on the design and the trade-offs I made.

## Tests
    pytest

## Known limitations
- Amounts must use a dot as the decimal separator

## Licence
MIT

Line by line

  1. 1-3The title and a one-sentence description tell a visitor immediately what this is.
  2. 5-9A demo block with real output: showing the result is more convincing than describing it.
  3. 11-13Bullet the features rather than writing a paragraph.
  4. 15-18Installation uses a virtual environment and a requirements file so the steps work on a clean machine.
  5. 20-21One command that shows how to run it.
  6. 23-24Space for design notes; this is where you explain decisions.
  7. 26-27Tell readers how to run the tests.
  8. 29-30Be upfront about limitations.
  9. 32-33State the licence.

Check your README with a small scorer

Checklists are most useful when a program applies them. The scorer below looks at the text of a README and checks for the sections described in the last lesson: a title, a description, an installation heading, a usage heading, a tests heading, a licence heading and at least one code block. It is deliberately simple, because the goal is a reminder you can run on every project, not a perfect judge of quality.

The code uses re.search with re.IGNORECASE | re.MULTILINE so that ## Installation, ## installation and ### Install can all match. Each check is a name paired with a pattern, kept in a list so adding a rule is one line. The score is the share of checks that pass, and the function also returns the missing items so you know what to write next.

Treat the number as a prompt, not a grade. A README can contain every heading and still be unhelpful, and a short one can be perfect for a tiny script. What the tool is good at is catching things you forgot, such as the licence line or the test instructions.

python
import re

CHECKS = [
    ("title",        r"^#\s+\S"),
    ("description",  r"^#\s+.+\n+\S"),
    ("installation", r"^#{2,3}\s+install"),
    ("usage",        r"^#{2,3}\s+usage"),
    ("tests",        r"^#{2,3}\s+tests?"),
    ("licence",      r"^#{2,3}\s+licen[cs]e"),
    ("code example", r"^( {4}|\t)\S|```"),
]

def score_readme(text):
    flags = re.IGNORECASE | re.MULTILINE
    passed = [name for name, pattern in CHECKS if re.search(pattern, text, flags)]
    missing = [name for name, _ in CHECKS if name not in passed]
    return round(100 * len(passed) / len(CHECKS)), missing

good = """# demo-tool

Counts words in a file.

## Installation
    pip install -r requirements.txt

## Usage
    python count.py notes.txt

## Tests
    pytest

## Licence
MIT
"""

weak = "# demo-tool\nSome script."

for label, text in [("good", good), ("weak", weak)]:
    score, missing = score_readme(text)
    print(label, score, "missing:", missing)
Expected output
good 100 missing: []
weak 29 missing: ['installation', 'usage', 'tests', 'licence', 'code example']

Line by line

  1. 1re is the standard regular-expression module.
  2. 3-11A list of (name, pattern) pairs. Each pattern looks for a heading line or an indented code block.
  3. 13-17Run each pattern against the text, collect what passed and what did not, and return a percentage score and the missing names.
  4. 19-33A complete README and a sketchy one, as test inputs.
  5. 35-37Score both and print the result with the missing items.

The weak example passes the title and description checks but is missing installation, usage, tests, licence and any code example. That mirrors a common README problem: a one-line blurb with nothing a visitor can act on.

Git basics you will use every day

Git records snapshots of your project called commits. You stage the changes you want with git add, record them with git commit -m, look at the state with git status and at history with git log --oneline. Between your computer and GitHub sits a remote, usually called origin; git push sends your commits there and git pull brings others' changes back.

Branches let you try something without disturbing the main line. git switch -c feature-name creates and moves to a new branch, and after you finish you merge it back, directly or through a pull request on GitHub. Even on a solo project, working on a branch and merging keeps main always in a working state, and it teaches the workflow that teams use.

Learn two safety commands early. git diff shows exactly what you are about to commit, which catches debugging leftovers; and git restore <file> throws away uncommitted changes to a file, which is permanent, so look before you run it. If you have already pushed a mistake, prefer a new commit that fixes it over rewriting shared history.

A first repository (bash, run on your computer)run on your computer
git init
git status
git add README.md main.py
git commit -m "Add word counter with README"
git branch -M main
git remote add origin https://github.com/YOUR-NAME/word-counter.git
git push -u origin main

git switch -c add-tests
git add tests/
git commit -m "Add tests for empty and unicode input"
git switch main
git merge add-tests
git log --oneline

Line by line

  1. 1Turn the current folder into a git repository.
  2. 2See which files are new, changed or staged.
  3. 3-4Stage two files, then record them as a commit with a message.
  4. 5Make sure the main branch is called main.
  5. 6-7Connect the folder to an empty GitHub repository you created, and push the first time with -u so later pushes need no arguments.
  6. 9-11Create a branch for a new piece of work, stage the tests and commit them.
  7. 12-13Return to main and merge the finished branch.
  8. 14Show a compact history, one line per commit.

.gitignore, secrets and licences

A .gitignore file lists patterns of files git should not track. In a Python project that means virtual environments (.venv/), bytecode caches (__pycache__/), build output, editor settings and local data. Create it before your first commit: files that are already tracked stay tracked even if you add them to .gitignore later, and you would have to remove them with git rm --cached.

The most important rule is never to commit secrets: API keys, passwords, tokens and .env files. Git history is permanent, so deleting the file in a later commit does not remove it from earlier ones, and anyone can view it. Keep secrets in environment variables, commit an .env.example with placeholder values and, if a real key ever leaks, revoke it at the provider immediately; cleaning history is only a secondary step.

Licences tell others what they may do with your code. Without one, the default in most places is that nobody else has permission to use, copy or change it, even though it is visible. Common choices are MIT and BSD, which are very permissive, Apache-2.0, which permissive with an explicit patent grant, and GPL, which requires derivative works to stay open under the same terms. Pick the one that matches what you want, add a LICENSE file and mention it in the README. For a legal question about your own situation, ask a qualified person.

A starting .gitignore for Python (text)run on your computer
# environments and secrets
.venv/
venv/
.env

# python caches and build output
__pycache__/
*.pyc
.pytest_cache/
dist/
build/
*.egg-info/

# editors and operating system
.vscode/
.idea/
.DS_Store

# local data
data/private/
*.sqlite3

Line by line

  1. 1-4Virtual environments are large and machine-specific; .env often holds secrets.
  2. 6-11Generated files that can always be recreated.
  3. 13-16Personal editor settings and system files.
  4. 18-20Local data you do not want to publish, such as private datasets and databases.
⚠️

If you ever commit a real key, treat it as public: revoke it and create a new one before doing anything else.

Project structure that looks professional

A predictable layout lets a stranger find things without asking. The shape I recommend for a small application is a top-level folder with README.md, LICENSE, .gitignore, pyproject.toml or requirements.txt, a package folder holding the code, and a tests folder beside it. Put runnable entry points in a __main__.py or a small cli.py so the project can be started with python -m package_name.

A src/ layout, where the package sits inside src/, avoids accidentally importing from the working directory and is a good habit for anything you may publish; a flat layout is fine for small projects. Either way, keep modules small and named by what they do (parser.py, report.py), keep data samples in a data/ folder and keep documentation next to the code. See packaging for how this grows into an installable package.

The tool below prints a tree from a list of paths using only the standard library, which is handy for README 'Project layout' sections and for checking your own structure. It sorts entries so output is stable, puts folders before files, and draws the familiar branch characters.

python
def build_tree(paths):
    tree = {}
    for path in paths:
        node = tree
        for part in path.strip("/").split("/"):
            node = node.setdefault(part, {})
    return tree

def render(node, prefix=""):
    lines = []
    entries = sorted(node.items(), key=lambda kv: (not kv[1], kv[0]))
    for i, (name, child) in enumerate(entries):
        last = i == len(entries) - 1
        lines.append(prefix + ("└── " if last else "β”œβ”€β”€ ") + name + ("/" if child else ""))
        if child:
            lines.extend(render(child, prefix + ("    " if last else "β”‚   ")))
    return lines

files = [
    "README.md", "LICENSE", ".gitignore", "pyproject.toml",
    "expense_cli/__init__.py", "expense_cli/__main__.py",
    "expense_cli/reader.py", "expense_cli/report.py",
    "tests/test_reader.py", "tests/test_report.py",
    "data/sample.csv",
]

print("expense-cli/")
print("\n".join(render(build_tree(files))))
Expected output
expense-cli/
β”œβ”€β”€ data/
β”‚   └── sample.csv
β”œβ”€β”€ expense_cli/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ __main__.py
β”‚   β”œβ”€β”€ reader.py
β”‚   └── report.py
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_reader.py
β”‚   └── test_report.py
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
└── pyproject.toml

Line by line

  1. 1-7Turn slash-separated paths into nested dictionaries: each folder is a key whose value holds its children.
  2. 9-12For one level, sort so folders (non-empty dictionaries) come first, then alphabetical.
  3. 13-16Choose the branch symbol, add a trailing slash to folders, and recurse with an adjusted prefix so the vertical lines continue correctly.
  4. 19-26A sample project as a flat list of paths.
  5. 28-29Print the root folder name and then the rendered tree.

GitHub Pages, profile README and commit habits

GitHub Pages serves static files from a repository for free, which is ideal for a project demo or a small portfolio site made of HTML, CSS and JavaScript. In the repository settings you choose which branch (and folder) to publish, and a few minutes later the site is live at a github.io address. Python itself does not run on Pages, so use it for documentation, a generated report or a front end, and keep server code somewhere else.

Your profile README is a repository named exactly like your username, with a README.md in it; GitHub shows that file at the top of your profile. Keep it short: who you are, what you are learning or working on, links to your two or three best projects and a way to contact you. Resist badge walls and animated widgets that distract from the work.

Commit habits do more for your image than any badge. Make small commits that each do one thing, write the subject in the imperative mood (Add CSV export, not added stuff), keep it under about 50 to 72 characters, and add a body when the reason is not obvious. A common convention is a type prefix such as feat:, fix:, docs:, test: and refactor:. The validator below enforces a simple version so you can see how a rule becomes code.

python
import re

PATTERN = re.compile(
    r"^(feat|fix|docs|test|refactor|chore)"   # type
    r"(\([a-z0-9_-]+\))?"                    # optional scope
    r": "
    r"(?P<subject>\S.*)$"
)

def check_commit(message):
    problems = []
    subject = message.splitlines()[0] if message.strip() else ""
    match = PATTERN.match(subject)
    if not match:
        problems.append("use 'type: subject' (feat, fix, docs, test, refactor, chore)")
    else:
        text = match.group("subject")
        if len(subject) > 72:
            problems.append("subject longer than 72 characters")
        if text.endswith("."):
            problems.append("no full stop at the end of the subject")
        if text[0].isupper():
            problems.append("start the subject in lower case")
    return problems

messages = [
    "feat(report): add CSV export",
    "fixed stuff",
    "docs: Update the README.",
    "test: cover empty input",
    "",
]

for m in messages:
    issues = check_commit(m)
    print(repr(m), "->", "ok" if not issues else issues)
Expected output
'feat(report): add CSV export' -> ok
'fixed stuff' -> ["use 'type: subject' (feat, fix, docs, test, refactor, chore)"]
'docs: Update the README.' -> ['no full stop at the end of the subject', 'start the subject in lower case']
'test: cover empty input' -> ok
'' -> ["use 'type: subject' (feat, fix, docs, test, refactor, chore)"]

Line by line

  1. 3-8A compiled pattern: a type word, an optional scope in brackets, a colon and a space, then a non-empty subject captured under the name subject.
  2. 10-12Look only at the first line of the message; an empty message gives an empty subject.
  3. 13-15No match means the message does not follow the format.
  4. 16-23If it matches, add checks for length, a trailing full stop and an upper-case first letter.
  5. 26-32Five sample messages, good and bad.
  6. 34-36Print the problems found for each message.

Tools such as commit hooks can run a check like this automatically before each commit. For the longer story, add short 'decision notes' to your README or a docs/decisions.md file: one paragraph on each significant choice, what else you considered and why you chose this option. That writing is often the part readers remember.

Common mistakes

❌ Committing secrets or large junk files

API keys, .env files, virtual environments and datasets do not belong in the repository. Add a .gitignore before the first commit, keep secrets in environment variables and revoke anything that leaked.

❌ A repository with no README

Visitors will not read code to find out what a project does. Start with a one-line description, a demo and installation steps that you have tested on a clean machine.

❌ Giant commits with vague messages

Messages like update or fix stuff and commits that change twenty things make history useless. Commit one logical change at a time with an imperative, descriptive subject.

❌ Publishing code with no licence

Without a licence, others generally have no permission to reuse your work. Add a LICENSE file that matches your intention, and mention it in the README.

❌ Showcasing projects that do not run

If installation fails on a fresh clone, the project looks abandoned. Test in a new virtual environment, list dependencies and fix the steps until they work.

Quick quiz

Tap an answer. I explain every one, right or wrong.

Q1. Which command records staged changes as a commit?

Q2. You added .env to .gitignore after committing it. What is true?

Q3. What is the effect of having no licence on public code?

Q4. Which repository name creates your GitHub profile README?

Q5. What belongs first in a README?

Q6. Which is the best commit subject?

Frequently asked questions

Quality matters more than count. Three to five complete, documented projects that show different skills are plenty. Retire or archive anything you would not want a reader to judge you by.

You can include them if you clearly say so and add something of your own, such as a new feature, tests or a different data source. Projects with your own decisions are more convincing.

MIT is permissive and simple: others can reuse the code with few conditions. GPL requires derivative works to be shared under the same licence. Choose based on what you want others to be able to do, and read the licence text or ask a qualified person if the stakes are high.

No. It is useful for a demo site or documentation made of static files, but a good README is enough for most Python projects. Python code cannot run on Pages; it only serves static content.

Do not rewrite shared history for appearance. Start good habits from now on, write a clear README and use small commits and branches in the next projects. For a private, unpushed branch you can tidy commits before sharing.

Key takeaways

  • βœ“Choose a few finished projects that show different skills, and make sure each one runs from a fresh clone.
  • βœ“Write a README with a one-line purpose, a demo, tested installation steps, usage, tests, limitations and a licence.
  • βœ“Learn the daily git loop (status, add, commit, push) and use branches to keep main working.
  • βœ“Add .gitignore before the first commit and never commit secrets; revoke any key that leaks.
  • βœ“Add a LICENSE, a predictable folder layout and decision notes explaining why you built it that way.
  • βœ“Keep commits small with clear, consistent messages, and use GitHub Pages and a short profile README only to present real work.