Minimal effort to make slides and host an html file on Github
Sophia Yang
July 18, 2021
There are two parts to this article:
First, let's create a new environment slideshow
, install a Jupyter notebook extension RISE, and launch Jupyter Notebook:
conda create -n slideshow -c conda-forge python=3.9 rise
conda activate slideshow
jupyter notebook
Then create a Jupyter Notebook file as usual:
If you have code cells and would like to show all the code cells, use:
jupyter nbconvert github_page_example.ipynb --to slides --stdout > index.html
If you would like to hide all the code cells:
jupyter nbconvert github_page_example.ipynb --no-input --no-prompt --to slides --stdout > index.html
If you would like to hide code for certain cells, we can add a tag for those code cells via View - Cell Toolbar - Tags. Here I use the tag "remove_input".
jupyter nbconvert github_page_example.ipynb --TagRemovePreprocessor.remove_input_tags "remove_input" --to slides --stdout > index.html
1+1
2
Add tag "remove_input".
4
To publish an html file on Github Pages, we need to push to gh-pages
branch.
Create new git repo locally with gh-pages
branch:
git init
git checkout -b gh-pages
git add index.html
git commit
Go to Github and create a new empty repo, and then push our files to the gh-pages
branch.
git remote add origin git@github.com:YOUR_USER_NAME/YOUR_REPO_NAME.git
git branch -M gh-pages
git push -u origin gh-pages
Now you can see this slideshow hosted on a Github page: https://YOUR_USER_NAME.github.io/YOUR_REPO_NAME
Check mine out: https://sophiamyang.github.io/slides_github_pages/.