A template repo for a github.io blog site.
See the example site at https://brendanhasz.github.io/github-io-blog-template/
- Syntax highlighting via Rouge + Pygments 🌈
- LaTeX math rendering via MathJAX 🤓
- Auto dark mode 😎
- Comments via Disqus 💬
- Post tags (can filter posts by tag on the main page)
- RSS feed
Screen size | Light | Dark |
---|---|---|
Full-width: | ||
Half-width: | ||
Mobile: |
-
Create a new repo from this repository template (at the top of this repo's main page, click the "Use this template" button to create your own copy of this repo). If you'd like your site to be at
http://your_github_username.github.io
, then name the new repositoryyour_github_username.github.io
. Otherwise you can name itwhatever_you_want
and it will be athttp://your_github_username.github.io/whatever_you_want
. -
Go to the repository settings for the new repository, and scroll down to the "GitHub pages" section. From the dropdown, select "main" (or whatever branch you want to build the site from). Then click "Save".
-
To test out your setup, in a browser go to
http://your_github_username.github.io
(or, if you gave the repo a custom name,http://your_github_username.github.io/repository_name
) and you should see the main page! Now you can edit the repo so it has your own info: -
Edit
_config.yml
to contain information about you and your new blog in the "Personal info", "Blog info", and "Social links" sections. Be sure to updateurl
to be the url of your blog with a trailing forward slash (i.e.http://your_github_username.github.io/
, or if you named your reposomething_else
, thenhttp://your_github_username.github.io/something_else/
). -
If this is your main
github.io
site (i.e. the repo name isyourgithubusername.github.io
), then in_config.yml
set the value ofmain_github_io
totrue
. Otherwise, leave it asfalse
. -
Add an image of yourself to the
/assets/img
folder, and in_config.yml
, update the value oflogo
to be the filename of that image. -
Replace
/assets/img/favicon.ico
with one you want (otherwise it will just be the default github octocat one, you can use a web utility like https://favicon.io/ to convert normal images to favicons) -
Replace
/assets/img/company_icon.png
with the logo of your company/university. -
Replace
/assets/img/blog_og_image.png
with image you'd like displayed when people share a link to your blog (e.g. on twitter, linkedin, etc) -
Replace
/assets/files/resume.pdf
with your resume (or delete it). -
Delete the example blog posts in
_posts
and replace with your first blog post(s)! (see below)
To add a new post, just add a markdown file to the _posts
folder!
The header of each post defines some important information (the lines surrounded by ---
at the top):
title
: the title for the postdate
: the date of the post. Note you can actually write and post posts ahead of time, and they won't be displayed until thedate
in the headerdescription
: a shortish description for the post. This will be displayed on the post list on the main page.img_url
: path to the image you want to show for this post on the main pagetags
: a list of tags you want for this post. On the main page you can filter posts by tag.github_url
: (optional) a url to a github repository with code (or whatever) relevant to this post (will show a link at the top of the post)colab_url
: (optional) a url to a Google Colab notebook relevant to this post (will show a link at the top of the post)kaggle_url
: (optional) a url to a Kaggle notebook relevant to this post (will show a link at the top of the post)
See the example posts in the _posts
folder for example markdown content, including sections, links, lists, code blocks, equations, images, etc.
You can add images for your post(s) in /assets/img
. I usually have a folder in /assets/img
for each blog post, just to keep things tidy.
github.io
site (i.e. if the repo name is yourgithubusername.github.io
, then do ![](/assets/img/some_img.png)
). Otherwise, you don't need the leading forward slash (e.g. ![](assets/img/some_img.png)
).
By default, dark mode will be used for people viewing the page with their computer/browser preferences set to "Dark". To force the light theme, in _config.yml
set color_mode
to light
. Or, to force the dark theme, in _config.yml
set color_mode
to dark
.
To enable comments on your posts via Disqus, first you'll need to sign up for a Disqus account and register your new site.
Then, in _config.yml
, set comments
to true
, and set disqus_shortname
to your site's Disqus shortname.
To change the syntax highlighting that's used for code blocks, download the CSS file for the syntax highlighting you want (you can see a preview of different themes here, and you can download the css file for the one you want here). Add that CSS file to the /assets/css
folder, and in _config.yml
, change the value of syntax_highlight_stylesheet
to be the name of that file.
You can change the colors for different elements by setting their values in _config.yml
(towards the bottom). These are just hex color codes. You can also just edit the CSS manually (in /assets/css/main.css
).
The base html which serves as the template for all pages on the site is in /_layouts/default.html
. Edit it as you want!
The CSS for the site is in /assets/css/
folder.
Other than that, it's just a regular github pages site, so see all their documentation about customization.
You can feel free to copy/use any of this without restrictions (MIT license).
The placeholder headshot.svg file is CC-BY-SA by East718 (but you'll probably be replacing that with an image of yourself).