Run Jekyll GitHub pages locally
Debug a Jekyll GitHub page which hasn’t been run locally before
I was adding a
posts-by-tags page to my Jekyll blog. Previously I have gotten away with never running the Jekyll site locally thanks to GitHub actions however while adding a new feature I came across a generic error I needed to debug locally.
Undefined method gsub for integer
Below is the error message:
Liquid Exception: undefined method `gsub' for 2003:Integer
Upon searching this someone else had a similar issue but this didn’t help me to narrow this down enough to fix it: Liquid Exception: undefined method `gsub’ for 2012:Integer in /_layouts/post.html
Looking at the official Jekyll docs we get some pointers on how to setup the local development environment: https://jekyllrb.com/docs/
- I run the following commands which clone my blog to the local machine.
- The Jekyll new will need to have
blogreplaced with whatever your repos name is.
--forceflag will overwrite anything that conflicts with a Jekyll template config.
.gitignoreis really all it adds, you should still run with
--forceso the URLs are
- I just scrap the changes in
jekyll newbesides the ones I manually made to patch the bugs once I am done debugging.
git clone https://github.com/2E0PGS/blog.git jekyll new blog --force bundle exec jekyll serve
My particular bug turned out to be I had a tag which was just a lone int:
I fixed and finished implementing my
posts-by-tags page in commits:
After fixing the first bug I then came across a second bug thanks to a large code block I had in another post with lots of special chars.
Jekyll Feed: Generating feed for posts
I fixed this in commit: af7a60060b2bab05d0805d1443e1674a4d8e26b9 with my custom variable:
Checkout the following variables more:
Add the actual RSS feed error instead of the line before the error.
Let me know what you think of this article on twitter @M3PGS or leave a comment below!