source: Testing your GitHub Pages site locally with Jekyll
Open TerminalTerminalGit Bash.
Navigate to the publishing source for your site. For more information, see Configuring a publishing source for your GitHub Pages site.
Run bundle install.
Run your Jekyll site locally.
$ bundle exec jekyll serve
> Configuration file: /Users/octocat/my-site/_config.yml
> ... ... ...
> Server address: http://127.0.0.1:4000/
> Server running... press ctrl-c to stop.
[!NOTE]
- If you’ve installed Ruby 3.0 or later (which you may have if you installed the default version via Homebrew), you might get an error at this step. That’s because these versions of Ruby no longer come with
webrickinstalled.To fix the error, try running
bundle add webrick, then re-runningbundle exec jekyll serve.- If your
_config.ymlfile’sbaseurlfield contains your GitHub repository’s link, you can use the following command when building locally to ignore that value and serve the site onlocalhost:4000/:bundle exec jekyll serve --baseurl=""
To preview your site, in your web browser, navigate to http://localhost:4000.
[!NOTE] While the
github-pagesgem remains supported for some workflows, GitHub Actions is now the recommended approach for deploying and automating GitHub Pages sites.
Jekyll is an active open source project that is updated frequently. If the github-pages gem on your computer is out of date with the github-pages gem on the GitHub Pages server, your site may look different when built locally than when published on GitHub. To avoid this, regularly update the github-pages gem on your computer.
github-pages gem.
bundle update github-pages.gem update github-pages.