Skip to content

Instantly share code, notes, and snippets.

@MichaelCurrin
Last active February 8, 2023 13:19
Show Gist options
  • Save MichaelCurrin/3e5e063a89196eca997cac34e7678c77 to your computer and use it in GitHub Desktop.
Save MichaelCurrin/3e5e063a89196eca997cac34e7678c77 to your computer and use it in GitHub Desktop.
Set up a new Jekyll project

Set up a new Jekyll project

This short guides shows you how to setup a new skeleton Jekyll project, using the Jekyll CLI to generate the files for you.

This guide does not require Jekyll to be installed globally. Rather, it takes you through installing Jekyll in a new project that only has one file in it, then uses that project Jekyll to create all the Jekyll base files in the same directory.

Under Jekyll docs, you can see the Installation page. That provides links to install for each OS. These are covered in some detail here.

See also New under my Jekyll recipes for a few ways to set up a new Jekyll site.

Install Ruby and Bundler

Install Ruby 2.7 and then Bundler as a global gem. Follow instructions in gist.

Don't install Jekyll globally with gem or bundler unless you really have a usecase for that. Your projects will be more robust and easier to run on different machines (including those of other developers) if you ensure Jekyll gets installed at the project gems level, not the global level.

Set up Jekyll from a template repo

If you like, you can see a template repo at MichaelCurrin/jekyll-blog-demo. You can pick that or add it to your own repos, then clone it and install.

Or, continue below for a flow where you use the Jekyll new command rather to bootstrap a project.

Setup project using Jekyll new command

I cover here how to initialize project with Jekyll and no content first. Then I cover I how to use the jekyll new to create a new template Jekyll project.

Create a new project and add Jekyll to it.

$ mkdir my-project
$ cd my-project
$ bundle config set --local path vendor/bundle

$ echo 'source "https://rubygems.org"

gem "jekyll", "~> 3.9"
' > Gemfile

$ bundle install

Side note - you could use bundle init to generate a new Gemfile, but it adds things you don't need.

Now you can add your content.

If you want to initialize your project with Jekyll's base project, use this. It will use the currently installed Jekyll to create a new Jekyll project in the current directory. Overwriting your existing Gemfile.

$ bundle exec jekyll new . --force
$ ls
404.html     Gemfile      Gemfile.lock _config.yml  _posts       about.md     index.md     vendor

Make sure you have Kramdown GH Parser listed as a gem in Gemfile, otherwise Jekyll won't serve.

gem "jekyll", "~> 3.9"
gem "kramdown-parser-gfm", "~> 1.1"

Configure Bundler again and install Gems.

$ bundle config set --local path vendor/bundle
$ bundle install

Now you're ready to serve.

$ bundle exec jekyll serve --trace --livereload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment