Skip to content

Instantly share code, notes, and snippets.

@danielTobon43
Last active May 31, 2022 19:34
Show Gist options
  • Save danielTobon43/e2193be772e30e223c0c22f4290e771f to your computer and use it in GitHub Desktop.
Save danielTobon43/e2193be772e30e223c0c22f4290e771f to your computer and use it in GitHub Desktop.
Testing your GitHub page locally

Testing GitHub pages locally

Prerequisites

Before you can use Jekyll to test a site, you must:

Install Jekyll.
Create a Jekyll site. For more information, see "Creating a GitHub Pages site with Jekyll."

We recommend using Bundler to install and run Jekyll. Bundler manages Ruby gem dependencies, reduces Jekyll build errors, and prevents environment-related bugs. To install Bundler:

Install Ruby. For more information, see "Installing Ruby" in the Ruby documentation.
Install Bundler. For more information, see "Bundler."

Building your site locally

Open Terminal.
Navigate to the publishing source for your site. For more information about publishing sources, see "About GitHub Pages."
Run bundle install.
Run your Jekyll site locally.

$ bundle exec jekyll serve
> Configuration file: /Users/octocat/my-site/_config.yml
>            Source: /Users/octocat/my-site
>       Destination: /Users/octocat/my-site/_site
> Incremental build: disabled. Enable with --incremental
>      Generating...
>                    done in 0.309 seconds.
> Auto-regeneration: enabled for '/Users/octocat/my-site'
> Configuration file: /Users/octocat/my-site/_config.yml
>    Server address: http://127.0.0.1:4000/
>  Server running... press ctrl-c to stop.

To preview your site, in your web browser, navigate to http://localhost:4000.

Jekyll

To get started, I encourage you to follow the instructions on the GitHub Help: Using Jekyll with Pages website. Installing Jekyll

The installation of Jekyll depends on Ruby and Bundler. To install Bundler, run the command

$ gem install bundler

To install Jekyll, run the command

$ gem install jekyll

Using Jekyll

The basic jekyll command to create a basic jekyll directory called myrepo is jekyll new:

$ jekyll new myrepo $ cd myrepo $ git init

If the repo is empty there will be no error messages. If the repo is not empty, it will complain about there being files already in the repo. Just move the files to a different places temporarily and rerun the command. A new set of files should appear in the directory. Copy all of the files you moved back into the repo and run this command in the myrepo directory:

$ jekyll build $ jekyll serve

gem "jekyll-jupyter-notebook"
gem "jekyll-paginate"
gem "jekyll-latex"
gem 'jekyll-seo-tag'
gem 'jekyll-twitter-plugin'
gem 'jekyll-theme-cayman'
gem 'jekyll-sitemap'
gem 'jekyll-feed'
gem 'jekyll-scholar', group: :jekyll_plugins
group :jekyll_plugins do
gem 'jekyll-commonmark-ghpages'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment