In Part 1 we integrated Bootstrap 4 into our Jekyll site. In this post, we’ll expand the site to include navigation, a banner and a footer section. We’ll mostly be dealing with standard Bootstrap and HTML, with a little bit of Jekyll thrown in.
I’d encourage you to follow along, but if you want to skip directly to the code, it’s available on GitHub at: https://github.com/riebeekn/jekyll-bootstrap-4-starter.
What we’ll build
At the end of this post, our site will look like:
Getting started
If you followed along with part 1 just continue on with the code you created in part 1. If not and you’d rather jump right into part 2, you can use a clone of part 1 as a starting point.
Clone the Repo
If grabbing the code from GitHub instead of continuing along from part 1, the first step is to clone the repo.
Terminal
What we’re starting with
OK, you’ve either gotten the code from GitHub or are using the existing code you created in Part 1, let’s see where we’re starting from.
Terminal
If you navigate to http://localhost:4000/ you’ll see where we left off last time.
Let’s start things off by adding a navigation bar.
Adding a navigation bar
First order of business is to create a file to hold the navigation markup, which we’ll place in the include directory.
Terminal
Now comes the HTML for our navigation. We expect to eventually have archive
and about
pages so we’ll create links for those as well as the standard home
and brand
links.
/_includes/header.html
Nothing out of the ordinary, just standard Bootstrap, the only thing of note from a Jekyll perspective is that we’re using {{ site.baseurl }}
in our link tags. This ensures our links are valid based on where our site is running from. For instance, when running locally, our about page will go to http://localhost:4000/about. When deployed to an actual URL, the proper URL will replace localhost:4000
.
Let’s tweak our layout file to include the new header section.
/_layouts/default.html
All we’ve done is add the header before our {{ content }}
section.
With that, we have navigation!
The text for the navigation items is a little small, and we’d also like to change the color of the links. A bit of styling will fix that up.
Terminal
/css/custom/includes/_header.scss
We’ve also added a minor box shadow to the header.
We’re going to over-ride the info
Bootstrap variable to get the desired color on our links:
/css/custom/_variables.scss
In order for the styles to be applied, we’ll need to import them in main.scss
.
/css/main.scss
While we are at it, let’s remove the contents of index.html
.
/index.html
That looks better:
Adding a banner
Next up, let’s add a simple banner under our navigation header. We’ll start by creating a new file to hold the banner markup:
Terminal
The banner markup itself is very simple. We’re using standard HTML / Bootstrap with the exception of a custom primary-overlay
class, which we’re going to use to style the banner. We’re using 2 columns in order to nudge the text to the left side of the banner.
/include/banner.html
We need to add the banner to our layout:
/_layouts/default.html
We’ve specified text-white
in our banner so until we add some styling, we won’t be able to see the banner. Let’s create a Sass file to contain the banner styles.
Terminal
And we’ll need to import the new Sass file in main.scss
.
/css/main.scss
Before adding our style, let’s also create an img
directory as we’ll use an image as part of the banner.
Terminal
Download the following image from Pexels
https://www.pexels.com/photo/shadow-of-person-on-water-during-daytime-38069/ and add it to the img directory, renaming it to banner.jpeg
. I used the medium size image… and didn’t spend much time searching for an image, I figured boots for Bootstrap!
Let’s get around to our styling.
/custom/includes/_banner.scss
We’re setting the image as the background and then applying an overlay via the .primary-overlay
style.
And with that, we should have a decent looking banner:
Adding a footer
Our final task is to add a footer. We’ve already got a file for our footer but it currently just contains our javascript links. We want to add a general copyright notice and a few social links where people can find out more information about us.
/_includes/footer.html
A couple of things to make note of here:
- Instead of directly inserting our social links, we’re using Jekyll’s built in social icon configuration.
- We’re including a
social_links.html
page that we’ll need to create.
Let’s create a file for the social links.
Terminal
Next add the following to the existing configuration file and restart the Jekyll server so the new settings are picked up.
/_config.yml
We’ve set our user-names and whether the social icons should appear in the configuration file. You could forgo this approach and instead place the links directly in footer.html
or a seperate include file; but this approach does provide a little additional flexibility.
Let’s fill in the social_links.html
page.
/_includes/social_links.html
Pretty straight-forward, we’re simply linking to GitHub / Twitter, but grabbing the username to link to from _config.yml
. Notice we’ve also added an email link that makes use of the email
setting in _config.yml
.
And our footer looks like:
I think a bit of styling would help out those links, so let’s create and import a new Sass file for the links.
Terminal
/css/main.scss
Now let’s fill in the styles.
/css/custom/includes/_social_links.scss
Nothing crazy here, we’re just getting rid of the underline in the links, adding a bit of padding and adjusting how things look on mouse hover.
Summary
In this post, we’ve added navigation, a banner and a footer to the site. Things are starting to come together! Next time, we’ll add post pagination and a simple about and archive page.
Thanks for reading and I hope you enjoyed the post!