* Update creating-a-github-pages-site-with-jekyll.md The previous instructions for installing the `github-pages` gem via the Gemfile were confusing. If you search for `could not find gem github-pages` in your favorite search engine, you'll find many people didn't uncomment the line and/or tried to run `bundle update github-pages` instead of `bundle install`. This is my attempt to make things clearer by being more specific step by step. * Update step 7 as well I was initially focused on steps 8-10, but I thought I should try all of the commands to make sure everything works. As far as I can tell, you cannot pass in a version number to the `jekyll new` command, at least not the way it was documented here. Also, the Bundler section is more confusing than helpful because for `bundle exec` to work, a Gemfile must exist in the directory, but the instructions don’t mention that. Instead of adding more steps, I thought it was easier to skip that section. Because people installing Jekyll today will have version 4.2.0, and because github-pages only supports 3.9.0, one must run `bundle update` instead of `bundle install` to resolve all dependencies. * Update content/github/working-with-github-pages/creating-a-github-pages-site-with-jekyll.md Co-authored-by: Ben Whetton <ben.whetton@gmail.com> * Update content/github/working-with-github-pages/creating-a-github-pages-site-with-jekyll.md Co-authored-by: Ben Whetton <ben.whetton@gmail.com> * Update content/github/working-with-github-pages/creating-a-github-pages-site-with-jekyll.md Co-authored-by: hubwriter <hubwriter@github.com> * Update content/github/working-with-github-pages/creating-a-github-pages-site-with-jekyll.md Co-authored-by: hubwriter <hubwriter@github.com> * Update creating-a-github-pages-site-with-jekyll.md Co-authored-by: Moncef Belyamani <moncef@example.com> Co-authored-by: Ben Whetton <ben.whetton@gmail.com> Co-authored-by: hubwriter <hubwriter@github.com>
5.4 KiB
title, intro, product, redirect_from, permissions, versions
| title | intro | product | redirect_from | permissions | versions | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Creating a GitHub Pages site with Jekyll | You can use Jekyll to create a {% data variables.product.prodname_pages %} site in a new or existing repository. | {% data reusables.gated-features.pages %} |
|
People with admin permissions for a repository can create a {% data variables.product.prodname_pages %} site with Jekyll. |
|
{% data reusables.pages.org-owners-can-restrict-pages-creation %}
Prerequisites
Before you can use Jekyll to create a {% data variables.product.prodname_pages %} site, you must install Jekyll and Git. For more information, see Installation in the Jekyll documentation and "Set up Git."
{% data reusables.pages.recommend-bundler %}
{% data reusables.pages.jekyll-install-troubleshooting %}
Creating a repository for your site
{% data reusables.pages.new-or-existing-repo %}
{% data reusables.repositories.create_new %} {% data reusables.repositories.owner-drop-down %} {% data reusables.pages.create-repo-name %} {% data reusables.repositories.choose-repo-visibility %}
Creating your site
{% data reusables.pages.must-have-repo-first %}
{% data reusables.pages.private_pages_are_public_warning %}
{% data reusables.command_line.open_the_multi_os_terminal %} 2. If you don't already have a local copy of your repository, navigate to the location where you want to store your site's source files, replacing PARENT-FOLDER with the folder you want to contain the folder for your repository.
$ cd <em>PARENT-FOLDER</em>
- If you haven't already, initialize a local Git repository, replacing REPOSITORY-NAME with the name of your repository.
$ git init <em>REPOSITORY-NAME</em>
> Initialized empty Git repository in /Users/octocat/my-site/.git/
# Creates a new folder on your computer, initialized as a Git repository
- Change directories to the repository.
$ cd <em>REPOSITORY-NAME</em>
# Changes the working directory
{% data reusables.pages.decide-publishing-source %}
{% data reusables.pages.navigate-publishing-source %}
For example, if you chose to publish your site from the docs folder on the default branch, create and change directories to the docs folder.
$ mkdir docs
# Creates a new folder called docs
$ cd docs
If you chose to publish your site from the gh-pages branch, create and checkout the gh-pages branch.
$ git checkout --orphan gh-pages
# Creates a new branch, with no history or contents, called gh-pages and switches to the gh-pages branch
-
To create a new Jekyll site, use the
jekyll newcommand:$ jekyll new . # Creates a Jekyll site in the current directory -
Open the Gemfile that Jekyll created.
-
Add "#" to the beginning of the line that starts with
gem "jekyll"to comment out this line. -
Add the
github-pagesgem by editing the line starting with# gem "github-pages". Change this line to:gem "github-pages", "~> GITHUB-PAGES-VERSION", group: :jekyll_pluginsReplace GITHUB-PAGES-VERSION with the latest supported version of the
github-pagesgem. You can find this version here: "Dependency versions."The correct version Jekyll will be installed as a dependency of the
github-pagesgem. -
Save and close the Gemfile.
-
From the command line, run
bundle update. -
Optionally, test your site locally. For more information, see "Testing your {% data variables.product.prodname_pages %} site locally with Jekyll."
-
Add your {% data variables.product.product_name %} repository as a remote, replacing {% if enterpriseServerVersions contains currentVersion or currentVersion == "github-ae@latest" %}HOSTNAME with your enterprise's hostname,{% endif %} USER with the account that owns the repository{% if enterpriseServerVersions contains currentVersion or currentVersion == "github-ae@latest" %},{% endif %} and REPOSITORY with the name of the repository.
{% if currentVersion == "free-pro-team@latest" %}
$ git remote add origin https://github.com/<em>USER</em>/<em>REPOSITORY</em>.git
{% else %}
$ git remote add origin https://<em>HOSTNAME</em>/<em>USER</em>/<em>REPOSITORY</em>.git
{% endif %}
- Push the repository to {% data variables.product.product_name %}, replacing BRANCH with the name of the branch you're working on.
$ git push -u origin <em>BRANCH</em>
{% data reusables.pages.configure-publishing-source %} {% data reusables.pages.navigate-site-repo %} {% data reusables.repositories.sidebar-settings %}{% if currentVersion == "free-pro-team@latest" %} {% data reusables.pages.choose-visibility %}{% endif %} {% data reusables.pages.visit-site %}
{% data reusables.pages.admin-must-push %}
Next steps
To add a new page or post to your site, see "Adding content to your {% data variables.product.prodname_pages %} site using Jekyll."
{% data reusables.pages.add-jekyll-theme %} For more information, see "Adding a theme to your {% data variables.product.prodname_pages %} site using Jekyll."