Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll remote theme doesn't work locally

Abstract

  • I wanted to see a page in the local machine made by Jekyll using gem "jekyll-remote-theme"
  • So I ran bundle exec jekyll serve
  • But a blank page came out

What I want to achieve

  • To see a page in the local machine made by Jekyll using gem "jekyll-remote-theme".

I'm trying to build a blog in GitHub Pages with Jekyll and Minimal Mistakes. Before I push changes, I'd like to check if everything's fine with the pages.

Environment

  • Windows 8.1 64bit
  • ruby 2.4.3p205 (2017-12-14 revision 61247) [x64-mingw32]
  • Jekyll 3.6.2

What I did

  1. bundle exec jekyll new . --force
  2. Installed the theme with GitHub Pages Method
  3. bundle exec jekyll serve

What actually happened

I had an error related to libcurl.dll. Here is the message on Powershell.

Dependency Error: Yikes! It looks like you don't have jekyll-remote-theme or o ne of its dependencies installed. In order to use Jekyll as currently configured , you'll need to install this gem. The full error message from Ruby is: 'Could n ot open library 'libcurl': (illegal characters) . Could not open libr ary 'libcurl.dll': (illegal characters) . Could not open library 'lib curl.so.4': (illegal characters) . Could not open library 'libcurl.so .4.dll': (illegal characters) ' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!

I followed instructions in GitHub Pages Dependencies Missing · Issue #17 · benbalter/jekyll-remote-theme and the problem was solved.

Then another error came up with bundle exec jekyll serve. The page locally created is blank. http://127.0.0.1:4000/ shows nothing.

PS E:\workspace\mysite\dixhom.github.io> bundle exec jekyll serve
Configuration file: E:/workspace/mysite/dixhom.github.io/_config.yml
            Source: E:/workspace/mysite/dixhom.github.io
       Destination: E:/workspace/mysite/dixhom.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
      Remote Theme: Using theme mmistakes/minimal-mistakes
     Build Warning: Layout 'single' requested in _posts/2018-02-06-welcome-to-jekyll.markdown does not exist.
     Build Warning: Layout 'default' requested in 404.html does not exist.
     Build Warning: Layout 'page' requested in about.md.bak does not exist.
     Build Warning: Layout 'home' requested in index.html does not exist.
     Build Warning: Layout 'home' requested in index.md.bak does not exist.
                    done in 5.423 seconds.
 Auto-regeneration: enabled for 'E:/workspace/mysite/dixhom.github.io'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

It looked like jekyll couldn't read layout files. In addition, the _layouts directory wasn't in the directory where I did bundle exec jekyll new. But by default, what's in the _layouts directory is packaged in a theme so it's normal not to see the directory. So I just copied _layouts from minimal-mistakes GitHub repo to the local directory as a workaround.

Then, another error was raised.

PS E:\workspace\mysite\dixhom.github.io> bundle exec jekyll serve
Configuration file: E:/workspace/mysite/dixhom.github.io/_config.yml
            Source: E:/workspace/mysite/dixhom.github.io
       Destination: E:/workspace/mysite/dixhom.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
      Remote Theme: Using theme mmistakes/minimal-mistakes
  Liquid Exception: Could not locate the included file 'sidebar.html' in any of ["E:/workspace/mysite/dixhom.github.io/_
includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site sourc
e. in /_layouts/single.html
jekyll 3.6.2 | Error:  Could not locate the included file 'sidebar.html' in any of ["E:/workspace/mysite/dixhom.github.i
o/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site so
urce.

I could have just copied _includes the same way but I believe the core of the problem lies in jekyll failing to read necessary files from, for example, a GitHub repo.

The weird thing is when I push local changes to GitHub, GitHub Pages shows a properly rendered page as shown below.

enter image description here

By the way, the repo is https://github.com/Dixhom/dixhom.github.io/tree/7132905f5515345eb78cd71bdad168a15f906a1c

I suspected jekyll-remote-theme doesn't work on the local environment so I googled "jekyll remote theme serve" which wasn't helpful.

Googling keywords like "remote theme Build Warning: Layout does not exist." didn't help much.

  • jekyll - Github Pages renders blank page - Stack Overflow
    Different. Working on the local machine not on the github pages
  • Jekyll on github doesn't works the same as local jekyll server - Stack Overflow
    Same.
  • Jekyll works locally but comes up blank on github pages - Help - Jekyll Talk
    -Same.
  • Blank new blog generated with Jekyll-3.2.1 on Windows · Issue #5192 · jekyll/jekyll
    It seemed relevant at first sight, but it is about Gem based themes, not remote themes.

How can I solve this problem?

like image 884
dixhom Avatar asked Feb 11 '18 05:02

dixhom


People also ask

How do I run Jekyll theme locally?

You can check it locally( localhost:4000 or 127.0. 0.1:4000 ) whenever you update something and you want to check the result. Usually changing in _config. yml , you need to restart the jekyll serve (using ctrl+c to stop and run $ bundle exec jekyll serve to restart the service to check the modification.


Video Answer


1 Answers

aaaah I was just bashing my head against this as well. I ran bundle exec jekyll serve --verbose and saw that jekyll-remote-theme was never being initialized at all (each plugin logs a Requiring: jekyll-<thing> line). Then I noticed this block in the Gemfile:

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
end

I added "gem jekyll-remote-theme" to that plugin block and that fixed it – doh!

There are a few notes in the jekyll changelogs about this Gemfile group, but I didn't find any of it super helpful in explaining what's going on here.

hope that helps!

like image 95
Matt Avatar answered Oct 21 '22 09:10

Matt