ted
ted

Reputation: 4975

Can't preview Github pages

I am trying to build a github-pages site and to preview it offline. However, I have only partial success, while the page I get served comes from my offline sources, all its resources (css/img) and links point to the github location of the site.

I use {{ site.github.url }}, installed jekyll as described here.

I tried bundle exec jekyll clean, and attempted to git remote remove origin and to unset github_username. However, without the remote the site would not build and with it (without a username), it still knew my username as it still generated links to <username>.github.io/repo/ rather than 127.0.0.1:3000 (I changed the port).

How can I test my github pages offline properly (i.e. have the links point to my local jekyll instance)?

Important: When I fire up bundle exec jekyll serve I get the following warning:

GitHub Metadata: No GitHub API authentication could be found. Some fields > may be missing or have incorrect data.

As far as I am aware this comes from jekyll-github-metadata which populates site.github. And as such (I assume) site.github.url. However, I have not found if this caches data, and how to wipe this data. As I am trying to build an offline test I do want this url to be empty/ point to localhost.

===============================

Header layout excerpt:

<head>
<title>A title</a>
<link rel="stylesheet" href="{{ site.github.url }}/css/bootstrap.min.css">
</head>

As this <head> section/this layout is used in different parts of the page hierarchy, I need an absolute path to link to the css file.

Upvotes: 3

Views: 2359

Answers (2)

Chris Knight
Chris Knight

Reputation: 1476

If you are still experiencing this issue, I have a blog post and video showing how to fix it. The skinny of it is this:

  1. Create a personal access token in GitHub. This takes just a second, see GitHub’s documentation. When picking the scope(s) that you want to grant to the token, just select the repo checkbox.
  2. Add a new system environment variable on your machine named JEKYLL_GITHUB_TOKEN and set the value equal to the personal access token you generated.
  3. Go here, copy all the text in the page, and save it as a file named cacert.pem somewhere on your local machine.
  4. Add a new system environment variable on your machine named SSL_CERT_FILE and set the value equal to the full file path of where you saved the cacert.pem file.
  5. RESTART YOUR MACHINE (this is not optional)

The blog post assumes you are on a Windows machine, but the same steps should work on a Mac.

Upvotes: -1

David Jacquel
David Jacquel

Reputation: 52789

Replace : {{ site.github.url }}/css/bootstrap.min.css

by : {{ site.baseurl }}/css/bootstrap.min.css

Github metadata plugin provides common repository information and is not supposed to be used to generate your resources urls. I don't even see it mentioned in the documentation you're referencing.

You don't need it to have Jekyll working locally.

Upvotes: 2

Related Questions