Sprint 4
SASS for CSS, Github Pages, and Jekyll
SASS exercise đź“ť
Convert code snippet in exercise to SASS syntax. Try to remove as much duplication as possible.
In-class Assignments
Using Jekyll and Github Pages
In our last class we learned to build websites from scratch, this a useful skill but not always practical. It was a lot of work right? Making all of your pages look the same? Making navigation work the same on all of your pages so users don’t get lost?
When we’re building websites (and eventually web applications) there are a lot of little things that need to be consistent but a lot of little things can add up to a lot of work. That’s why we use frameworks. Frameworks take care of all those little things (and a couple of larger things too).
Jekyll
The framework we’ll set up today is called Jekyll. Jekyll was originally created to help build blogs but it can be applicable for many uses. What are some of those uses?
Jekyll provides a lot of benefits but we’re interested in these two specifically:
- lets us create pages in markdown which Jekyll compiles into HTML
- lets us easily create pages that look and behave consistently
Installing Jekyll and Dependencies
Sounds great! How do we get started? We have to install a lot of stuff! Follow these steps:
Creating Your New Blog, Generating HTML from Markdown and Serving Your New Blog
- Create your blog by running this command in the terminal:
jekyll new myblog
- Change into your new directory:
cd myblog
Open your editor and look around, what do you see? - Run the command that builds html files from the markdown files:
jekyll build
Open your editor and look around again, what do you see now? - Run the command that serves your site:
jekyll serve
What does the terminal say now? - Take the server address that the serve command output: http://127.0.0.1:4000/ And paste it into your web browser. What do you see? Who made this site?
- Press ctrl+c to stop the server
STOP! Version Control Time
We built a lot so far, and it has been exciting. Let’s keep our good habit of using version control to track changes in our projects. We’re going to create a GitHub pages repo for your project.
- Create a new repository named blog on GitHub.
- Clone the repository to your local computer using GitHub desktop. Click the “Set up in Desktop” button. When the GitHub desktop app opens, save the project.
- Using GitHub Desktop add your blog to this repository, commit all changes and push
- Navigate to github.com/username/blog/settings where username is you’re username. Scroll all the way down to the section GitHub Pages. Select the master branch from the source dropdown.
- Your blog should now be hosted at username.github.io/blog (it might take a few seconds)
Customizing Your Blog
Let’s customize your blog by editing the _config.yml
file
- Read the whole file. What do you think this file does?
- Change the Title, Email, Description and GitHub Username
- Run the command that builds and serves your site.
jekyll serve
Hint: jekyll serve will build and serve your site - Take the server address that the serve command output: http://127.0.0.1:4000/ And paste it into your web browser. What’s different?
- Press ctrl+c to stop the server
- Look around in your project in GitHub Desktop. What’s different?
- Add, commit and push your changes using Github Desktop.
- Give it a minute and check your blog at username.github.io/blog to see your changes
At-home Assignments
Up to now, we’ve been using Github Desktop to manage our project repositories on Github, but we haven’t dug into how git as a version control program works. Next session will will go into details about commits, best practices, how to contribute to other repositories via PRs, and how to give valuable comments. Being able to give useful and concise comments on a PR is a really good skill to have when looking for a job, and, just like everything else, it takes time and practice to master.
The at-home assignments this time are to help prepare for next week discussion and get you familiarized with git and Github:
Watch these videos
Assignments
- Create a blog post on your jekyll blog using the instructions below for “Creating Your First Blog Post.” Make sure you give your file a name with the YEAR-MONTH-DAY-title.markdown format.
Creating Your First Blog Post
- Create a markdown file with today’s date in the
_posts
directory. Your file name should look like this:2019-10-01-my-first-jekyll-post.markdown
- Make sure you include the front matter that indicates the layout and title of your blog:
--- layout: post title: "My First Jekyll Post" ---
- Add some content using markdown
- Run the command that builds and serves your site.
jekyll serve
- Take the server address that the serve command output: http://127.0.0.1:4000/ And paste it into your web browser. What’s different?
- Press ctrl+c to stop the server
- Add, commit and push your changes using Github Desktop.
- Give it a minute and check your blog at username.github.io/blog to see your changes