Running your Jekyll blog on a Local Server

less than 1 minute read

Introduction

I recently hit a stumbling block when trying to serve my Jekyll blog locally. After I ran the command ‘bundle exec jekyll serve’, I noticed that my local server would spin up, but the links would all point back to http://michaelcrump.net/whatever-blog-post. When they should be pointing to http://127.0.0.1:4000/whatever-blog-post.

The fix is quite simple:

Open your _config.yml file and add the following line (replace my domain name with yours):

	baseurl:          http://michaelcrump.net
	

Next, at your terminal prompt enter the following command to serve your site locally:

	bundle exec jekyll serve --baseurl ''
	


This simply overwrites the baseurl value with no value. Now simply navigate out to http://127.0.0.1:4000/ and your links should be pointing to the local version instead of your github page or custom domain.

Note: There are other ways that you can maintain two .yml files (one for development and one for production) located here.

I hoped this helped!

Leave a Comment