How to change the theme in your Jekyll application

- 2 mins

Follow these steps and you will be able to change the theme in your Jekyll application.

Create a new orphan branch and ensure it is empty.

git checkout --orphan newtheme
git rm -rf .
git clean -dfx

Now let’s add the theme’s repository as an upstream remote and pull the files into our branch. I am using Moon theme by Taylan Tatlı.

git remote add upstream
git fetch upstream
git pull upstream master

Install Gem dependencies and run your application to see if the previous steps were successful.

bundle install
jekyll serve

All okay so far? Good. Now it’s time to merge your blog posts, configuration and other custom files.

This will bring in your posts from master:

git checkout master -- _posts

You can safely merge these files and folders:

Some old files will conflict with ones from your new theme. The safest thing to do here is to copy the file to a new name and merge it manually.

git show master:_config.yml > _config.yml.old

Accidentally overwritten a theme file? No problem:

git checkout upstream/master --

I recommend manually merging these files:

Now replace master with the newtheme branch:

git checkout newtheme
git merge -s ours master --allow-unrelated-histories
git checkout master
git merge

Run the application again to see if your changes have come through:

jekyll serve

Push your changes:

git push

Leave no evidence of the crime by deleting the newtheme branch.

git branch -d newtheme


This solution is adapted from Daniel Pelsmaekerwith’s answer on StackOverflow to work with the latest versions of Git, Bundler and Jekyll.

rss facebook twitter github youtube mail spotify instagram linkedin google pinterest medium vimeo