Github Pages: Testing for local server

2 minute read

Before committing to github pages, you can upload your homepage locally through ruby and jekyll serve!

Installing Ruby + Devkit & Jekyll

After downloading Ruby, open the ruby prompt and enter gem install jekyll bundler to proceed with the installation.
After completing the installation, check if the installation was successful with jekyll -v.

TrobleShooting

1) Using bundle exec jekyll serve instead of jekyll serve

When I try to run jekyll serve command, sometimes I keep getting bundle errors. In this case, it can be easily solved by using the bundle exec jekyll serve command. It tells you what to do, so just follow the instructions in the Ruby prompt.

A message prompting you to bundle install or bundle update appears saying that bundle is not installed, so you can install it as it is.

D:\jjungs-page>jekyll serve
Traceback (most recent call last):
 10: from C:/Ruby26-x64/bin/jekyll:23:in `<main>'
  9: from C:/Ruby26-x64/bin/jekyll:23:in `load'
  8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/exe/jekyll:11:in `<top (required)>'
  7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/plugin_manager.rb:52:in `require_from_bundler'
  6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:149:in `setup'
  5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:26:in `setup'
  4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:26:in `map'
  3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/spec_set.rb:147:in `each'
  2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/spec_set.rb:147:in `each'
  1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:31:in `block in setup'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:312:in `check_for_activated_spec!': You have already activated i18n 1.7.0, 
but your Gemfile requires i18n 0.9.5. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

2) Change Gemfile and _config.yml files

If you get a message that your gemfile is a problem, updating Gemfile To solve the problem, you can do one of the two below.

  • Comment out the gem to remove(using #)
  • Add Gem to the Gemfile, and add it to the plugins: part of the _config.yml file.

3) run chcp 65001 cmd

If you get an Invalid CP949 character "\xE2" error message, this may be an encoding problem on Windows.

If you use UTF-8 encoding, Jekyll will break if a file starts with characters representing a BOM. Therefore, remove this sequence of bytes if it appears at the beginning of your file.
refer : jekyll page

D:\jjungs-page>bundle exec jekyll serve
Configuration file: D:/jjungs-page/_config.yml
            Source: D:/jjungs-page
       Destination: ./publishing
 Incremental build: disabled. Enable with --incremental
      Generating...
         AutoPages: Disabled/Not configured in site.config.
        Pagination: Complete, processed 2 pagination page(s)
       Jekyll Feed: Generating feed for posts
  Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/main.scss':
                    Invalid CP949 character "\xE2" on line 54
jekyll 3.8.6 | Error:  Invalid CP949 character "\xE2" on line 54
D:\jjungs-page>chcp 65001
Active code page: 65001

D:\jjungs-page>bundle exec jekyll serve

Finish

Go to local page(http://127.0.0.1:4000/) and testing local test. Then Update and pushing it.

D:\jjungs-page>bundle exec jekyll serve
Configuration file: D:/jjungs-page/_config.yml
            Source: D:/jjungs-page
       Destination: ./publishing
 Incremental build: disabled. Enable with --incremental
      Generating...
         AutoPages: Disabled/Not configured in site.config.
        Pagination: Complete, processed 2 pagination page(s)
       Jekyll Feed: Generating feed for posts
                    done in 6.677 seconds.
 Auto-regeneration: enabled for 'D:/jjungs-page'
    Server address: http://127.0.0.1:4000
  Server running... press ctrl-c to stop.
      Regenerating: 1 file(s) changed at 2021-05-05 22:2