Generated Sites

A static website contains only HTML, CSS and JS.
There is no server code or database.

A Static Site Generator is a computer program which
combines separate design and content into a static website.

Static site generators are helpful for creating simple sites
where you want to easily maintain the content separate from
the design, without using a CMS like wordpress.

Jekyll Logo

The most popular static site generator.

There are many static site generators,
each with different strengths.

Top static site generators

Jekyll was originally created for blogging,
but has evolved to support all kinds of sites.

Jekyll is a program that runs on your computer,
converting project files into a live website preview.

Jekyll is written using the Ruby programming language,
so we need to install Ruby and then install Jekyll.

Install Ruby

  • Windows
    Download and run the installer
    Download here
  • Mac
    Has Ruby pre-installed - yay!

Run the installer and complete the installation process.

Open a command line so that we can check
the status of our Ruby installation.

  • Mac
    Press Command + Space
    Type “Terminal”
    Press Enter

  • Windows
    Click “Windows”
    Click “Run”
    Type “cmd”
    Press Enter

You should have CMD or Terminal open.

To check if Ruby is installed correctly,
type in ruby -v and press enter.

The displayed Ruby version should be 2.0.0 or higher.

Install Jekyll

In your command window, type in
gem install jekyll and press enter.

Wait for the Jekyll installer to complete.

Check Jekyll is installed by typing in
jekyll -v and then pressing enter.

Your Jekyll version should be 3.0.0 or higher.

Creating a Project

Create a new folder on your computer with
a name for your site, for example jekyll-site.

This name can be changed later.

Create a folder called jekyll-site in a safe place.

Open the project folder in your favourite
text editor so we can begin adding files.

Open your project in a text editor.

Create an index page

Create an index.html in your project folder,
with the following code which should be familiar!

<!doctype html>
<html>

    <head>
        <title>My Jekyll Site</title>
    </head>

    <body>
        <h1>Hello!</h1>
    </body>

</html>

Make sure to save your index page!

Jekyll Configuration

Create a new file in your project called
_config.yml and add the following code.

name: Jekyll Site

It is also a good idea to specify
which version of Jekyll you are using.

name: Jekyll Site
version: 3.0.3

Make sure to save your configuration file!

Running Your Site

Using the command line,
navigate into your project folder.

Run your site from the command line by
typing jekyll serve and pressing enter.

In your browser, go to
http://localhost:4000/

You should see the word “Hello!”

Closing the command line will shut down your website preview.

The Site Folder

After running jekyll serve, you’ll see
that a folder called _site was created.

This is the generated output of your project.

Every time you make a change,
Jekyll updates the site folder.

If you were uploading to a web server which didn’t support Jekyll,
you would upload the contents of this folder.

Some hosting providers support Jekyll, which means
you can publish the working files and it will generate site.

GitHub and CloudCannon both support Jekyll.

Adding Pages

Extra pages can be added by making
a new HTML file for each page.

Create a new page called contact.html

<!doctype html>
<html>

    <head>
        <title>My Jekyll Site</title>
    </head>

    <body>
        <h1>Contact Me!</h1>
    </body>

</html>

Make sure to save your contact page!

Preview in your browser at localhost:4000/contact.html.

Summary

  • Config Files
    The config file tells Jekyll that the project folder is a Jekyll site.
  • Creating Pages
    Pages can be added by creating normal HTML files for each page.
  • Live Preview
    Serving your site with Jekyll enables browser preview.

Generated Sites: Complete

Next Chapter

Loading...