CSS Customization with Jekyll and GitHub Pages
Some minor customizations on the appearance of the website.
Table of Contents
File Structure
This is an example of how your local folder (and GitHub repository) should look like in terms of file structure.
- Root
- assets
- css
- main.scss
- css
-
_sass
- _posts
- _site
- assets
Specifically, in my case, on a default Jekyll minima site created locally (root folder docs), I need to:
- In
docs/assets, create a new folder namedcss. - Navigate to
gems/gems/minima-2.5.1folder - Copy the file
assets/main.scsstodocs/assets/css - Copy the folder
_sasstodocs.
Change Jekyll Code Block Background Colour
The default colour for code formatting is
#eef.
To change this colour, we need to edit two files:
_sass/minima/_syntax-highlighting.scss_sass/minima/_base.scss
In file 1, change the following
.highlighter-rouge & {
background: #eef;
to your desired colour. I used the default light grey colour defined in minima.scss file.
.highlighter-rouge & {
background: $grey-color-light;
In file 2, under Code formatting
delete background-color: #eef; from
pre,
code {
@include relative-font-size(0.9375);
border: 1px solid $grey-color-light;
border-radius: 3px;
background-color: #eef;
}
add your own colour code like this
pre {
padding: 8px 12px;
overflow-x: auto;
background: $grey-color-light;
To preview the change locally on your machine, save all files, make a draft post with some code blocks, and run Terminal command inside root folder:
$ bundle exec jekyll serve
To publish to GitHub Pages, push all above files and folders to your remote publishing repository.
Change Table Width on a Jekyll site
I write Python in Jupyter Lab and convert the notebook to markdown, the tables in my markdown file look like this
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
...
In my case, it is pretty simple to change the table width with a little CSS.
In _sass/minima/_layout.scss, add your customization
.dataframe {
table-layout: fixed;
width: $content-width;
td {
overflow:hidden;
}
}
Again, the $content-width is defined in minima.scss file.
Lastly, push all changes to the remote repository.