Project Portfolio Site¶
The behind the scenes of the site you are on right now :)
This site relies on MKdocs, a static site generator is written in python to create the content of the site, as well as the MKdocs Material Theme for customization. I used this same static site generator to create my Fab Academy Documentation Site, however, that site runs strictly on the MKdocs Material Theme without custom alterations. This site relies on the same structure as the prior Fab Academy Documentation Site but includes experiments with entirely custom components, and an altered MKdocs Material Theme. In addition to all that, it’s also built and hosted through my personal GitHub Pages repo, under my personal domain.
Repo Setup and Cloning¶
To start the site I created a new GitHub Pages repo on my GitHub and cloned in some of my site files from my prior Fab Academy Documentation Site (the cloned files were just so site setup files, as well as a bit of content on my Fab Academy final project to be displayed on this site). I then pulled this repo to my local system folder with the command
- Replace the text
REPO-HERE
with your site repo’s Clone with SSH link. This can be found under the Clone button in most Git web interfaces (i.e. Gitlab, Github, etc.).
Do I Need to Clone my Repo Locally?
Modern Hosting Platforms such as GitHub or GitLab allow for Repo editing to take place directly in the browser, and thus technically speaking, one does not need to pull their site Repo locally. However, browser editing eliminates the possibility of locally hosting, and thus one cannot view changes before pushing publically. Despite this, If you’d still like to work in a Browser-based editor, you may skip the SSH Setup and Site Publishing sections, and follow an editing and pushing workflow for your specific browser-based editor.
SSH setup¶
To clone a Git repository locally, an SSH key must be generated on your computer and then attached to your GitHub account. GitHub has really good documentation on creating a new SSH key and attaching it to your Git Web Interface (Github, Gitlab, etc.).
The process for generating and attaching a new SSH key to your Git Web Interface is relatively pain-free when following this documentation and using the command written above. My process involved running these commands …
ssh-keygen -t ed25519 -C "<Your-SSH-Name-Here>" # (1)
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519): # (2)
Enter passphrase (empty for no passphrase): # (3)
Enter the same passphrase again:
cat ~/.ssh/id_ed25519.pub | clip # (4)
-
This generates a new SSH key on your computer.
-
Click enter to confirm location.
-
Enter a passphrase for your SSH key, you will need this password whenever you attempt to push your site.
-
This copies your new SSH key to clipboard. Replace
id_ed25519.pub
with your filename. For example, useid_rsa.pub
for RSA.
Once copied to the clipboard, you can paste the newly generated SSH key in your SSH key settings in your Git Web Interface, to link your computer and your Git Web Interface. Now you can finally clone your site Repository locally as discussed above.
Mkdocs Material Install & Site Building¶
Requirements
Open your cloned GitHub Pages repo in your code editor of choice, my personal favorite source-code editor is Visual Studio Code, so naturally, I used it. In a new terminal in the clone site folder, run the command
Note for Fab Academy Students
The MKdocs Material theme is paired with the mkdocs-git-revision-date-localized-plugin by default in your Fab Academy student repo. This plugin enables displaying the date of the last git modification of a page at the bottom of each page. To build your static site, this plugin must be installed in your local site folder with the line below …
However, one may opt to not use it via the removal of the line
found under the plugins
section of your sites mkdocs.yml file.
Following this setup, I build my static site locally with the command in my site folders terminal
and followed the link given in my computer’s web browser. You should get an output like this after the mkdocs serve command …
Auto Site Building¶
GitHub Actions
The easiest way for your static site to be built in GitHub pages upon a push is through GitHub Actions allowing for an automated workflow to run to build and pipeline your static site publicly.
At the root of your repository, create a new GitHub Actions
workflow, e.g. .github/workflows/ci.yml
, and copy and paste the following
contents:
-
You can change the name to your liking.
-
At some point, GitHub renamed
master
tomain
. If your default branch is namedmaster
, you can safely removemain
, vice versa. -
This is the place to install further MkDocs plugins or Markdown extensions with
pip
to be used during the build.
For my site setup, I added the line …
… to install the Git Revision date plugin to my site, allowing for the date each page was updated to be displayed under all of the contents of the page.
Site Customisation¶
The basic setup and customization of your static site are covered wonderfully on the Mkdocs Material Theme Setup Documentation. However, following this basic theme setup, your site can be altered farther by extending the Material Theme - Witch can be read about here. All of my overrides can be found in this site’s GitHub repo.
Git Pull
When working with other developers in a Git Repo, the Git Pull command is necessary to keep your local branch up to date with others’ work. Running the line …
will pull in any pushed changes to your repository, allowing you to merge work/changes with work from other branches.
After working on teddywarner.org for a couple of months, I began to develop a project template page that accumulates different front-end HTML, CSS & Markdown aspects I use on my pages, which can be found via the button below.
Here I’ve also compiled a bit of a mkdocs markdown cheat sheet with 10 sections for customization, formatting, or additional flair. Again, the Mkdocs Material Theme Setup Documentation covers the theme-specific markdown at length and is a nice resource while setting up specific theme-specific bits. This section compiles theme-specific markdown with overall markdown features & all of the markdowns behind it can be found in the following sections, or on this page source - linked below.
1. Markdown Meta Data¶
2. Basic Syntax¶
3. Text Formatting¶
markdown_extensions:
- pymdownx.critic
- pymdownx.caret
- pymdownx.keys
- pymdownx.mark
- pymdownx.tilde
-
Bold Text -
**bold text**
-
Italicized Text -
*italicized text*
-
Strikethrough-~~Strikethrough~~
-
Subscript - H2O -
H~2~O
-
Superscript - X2 -
X^2^
4. Buttons¶
5. Different List Styles¶
“Unordered lists can be written by prefixing a line with a -
, *
or +
list marker, all of which can be used interchangeably. Furthermore, all flavors of lists can be nested inside each other:” 1
Result -
- Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis.
- Nullam dignissim ultrices urna non auctor.
- Nam vulputate tincidunt fringilla.
- Nam vulputate tincidunt fringilla.
- Nullam dignissim ultrices urna non auctor.
- Nullam dignissim ultrices urna non auctor.
- Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis.
“Ordered lists must start with a number immediately followed by a dot. The numbers do not need to be consecutive and can be all set to 1.
, as they will be re-numbered when rendered:” 2
Result -
-
Vivamus id mi enim. Integer id turpis sapien. Ut condimentum lobortis sagittis. Aliquam purus tellus, faucibus eget urna at, iaculis venenatis nulla. Vivamus a pharetra leo.
-
Vivamus venenatis porttitor tortor sit amet rutrum. Pellentesque aliquet quam enim, eu volutpat urna rutrum a. Nam vehicula nunc mauris, a ultricies libero efficitur sed.
-
Morbi eget dapibus felis. Vivamus venenatis porttitor tortor sit amet rutrum. Pellentesque aliquet quam enim, eu volutpat urna rutrum a.
- Mauris dictum mi lacus
- Ut sit amet placerat ante
- Suspendisse ac eros arcu
-
Result -
- Lorem ipsum dolor sit amet, consectetur adipiscing elit
- Vestibulum convallis sit amet nisi a tincidunt
- In hac habitasse platea dictumst
- In scelerisque nibh non dolor mollis congue sed et metus
- Praesent sed risus massa
- Aenean pretium efficitur erat, donec pharetra, ligula non scelerisque
Result -
Lorem ipsum dolor sit amet
-
Sed sagittis eleifend rutrum. Donec vitae suscipit est. Nullam tempus tellus non sem sollicitudin, quis rutrum leo facilisis.
Cras arcu libero
-
Aliquam metus eros, pretium sed nulla venenatis, faucibus auctor ex. Proin ut eros sed sapien ullamcorper consequat. Nunc ligula ante.
Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis. Nam vulputate tincidunt fringilla. Nullam dignissim ultrices urna non auctor.
6. Content Tabs, Code Styling & Annotations¶
markdown_extensions:
- attr_list
- md_in_html
- pymdownx.superfences
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- I’m a code annotation! I can contain
code
, formatted text, assets/images, … basically anything that can be expressed in Markdown.
PYTHON EXAMPLE | |
---|---|
7. Footnotes¶
Here’s a sentence with a footnote. 3
8. Formatted Tables¶
Method | Description |
---|---|
GET |
Fetch resource |
PUT |
Update resource |
DELETE |
Delete resource |
9. Admonitions¶
NOTE EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
INFO EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
ABSTRACT EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
TIP EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
SUCCESS EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
QUESTION EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
WARNING EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
FAILURE EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
DANGER EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
BUG EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
QUOTE EXAMPLE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
10. Icons & Emojis¶
markdown_extensions:
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
:fontawesome-regular-laugh-wink:
Site Publishing¶
Finally, after any changes are made to your site, you can merge your local changes back to your GitHub Pages repo to be built and published with the commands …
-
Stages all new changes made to your site.
-
Gives your push a title that will be visible on GitHub
-
Pushes changes to your GitHub - when prompted, enter your SSH password.
Congrats!
You now have built your very own static site with MKdocs and its Material Theme.
Wooo as of 12/01/2021, teddywarner.org is now 100 Commits old!!
200 Commits - 05/02/2022!
… and 300 Commits! - 06/28/2023!
400 Commits - 09/18/2024!