Project Structure and Configuration#
Sphinx reads the .rst files under source/ and writes a static site
to _build/html. Everything about how it does that is set in one file, source/conf.py. This page shows where
each file lives and which settings to change when you make the site your own.
Directory layout#
docs/
├── requirements.txt # Python packages to install
├── source/
│ ├── conf.py # Sphinx configuration
│ ├── index.rst # Home page (cards, latest posts)
│ ├── about.rst
│ ├── contact.rst
│ ├── _extra/CNAME # Copied to the site root; sets the custom domain
│ ├── _static/custom.css # Extra CSS
│ ├── _templates/ # Navigation bar and footer snippets
│ ├── posts/ # One .rst file per blog post, plus index.rst
│ └── projects/
│ ├── index.rst
│ ├── trade_engine.rst # Redirect page to separately built docs
│ └── personal_website/ # This section
└── _build/
└── html/ # Generated site; created by sphinx-build
_build is generated output. Delete it freely, and never edit files inside it.
Dependencies#
requirements.txt lists what the site needs:
Sphinx>=8.2
ablog>=0.11
numpydoc>=1.5
pydata-sphinx-theme>=0.16
sphinx-design>=0.6
sphinx-mathjax-offline>=0.0.2
sphinxcontrib-youtube>=1.4
Extensions#
Extensions add features to Sphinx and are listed in conf.py:
extensions = [
'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'ablog',
'sphinxcontrib.youtube',
'sphinx.ext.mathjax',
'sphinx-mathjax-offline',
'numpydoc',
'sphinx.ext.graphviz',
'sphinx_design',
'sphinx.ext.githubpages',
]
Extension |
What it is used for |
|---|---|
|
Blog posts, tags, categories, archives and the Atom feed (see Posts). |
|
Cards, grids, buttons, badges and tabs, such as the home page cards. |
|
Rendering maths written with |
|
The |
|
The |
|
Writes the |
|
Optional. Todo notes, link shortcuts, links to other projects’ docs, and NumPy-style docstrings. Remove any you
do not use, together with its line in |
Settings to change for your own site#
These settings in conf.py carry the author’s identity and address:
project = "Sam Khalilian"
author = "Sam Khalilian"
html_title = "Sam Khalilian" # browser tab title
blog_title = "Sam Khalilian"
blog_baseurl = "https://samkhalilian.dev/" # public address of the site; used for feed links
blog_authors = {"Sam Khalilian": ("Sam Khalilian", None)}
Setting |
What it controls |
|---|---|
|
Names used in the page titles and the footer. |
|
The address the feed links point to. Set it to where your site will really be served from. |
|
The names allowed in a post’s |
|
Files copied unchanged to the site root. |
|
Logo text, social links, banner and footer. See Theme and Customisation. |
Other values, such as language and today_fmt, can stay as they are.