thumb

We can set up a local version of our Jekyll GitHub Pages website to preview our website before making the changes public. But when I run the jekyll serve command it throws the following error message:

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

Here’s the solution to fix this warning:

Creating a GitHub personal access token.

In the upper-right corner of any page, click your profile photo, then click Settings.

In the left sidebar, click Developer settings.

In the left sidebar, click Personal access tokens.

Click Generate new token.

Give your token a descriptive name.

Select the scopes, or permissions, you’d like to grant this token. I will select the public_repo.

Click Generate token.

Copy the token to your clipboard. For security reasons, after you navigate off the page, you will not be able to see the token again.

Fixing the Jekyll + GitHub Metadata warning

Note! Treat your tokens like passwords and keep them secret (if you don’t want other people to use the API on your behalf). When working with the API, use tokens as environment variables instead of hardcoding them into your programs.

Open the ~/.bash_profile file (you can use your favorite text editor instead of nano if you’d like).

nano ~/.bash_profile

Note: This file may have different names and locations depending on your shell and OS. For example: .profile, .bashrc, .zshenv. In MacOS is a .bash_profile that loacated at user home directory (~/). You can search in Google for information about file in your OS in wich you can add a new environment variable.

Then define new environment variable with variable name JEKYLL_GITHUB_TOKEN and GitHub access token as variable value (which is something like abc123def456). You can do this by add the following line to a new blank line:

export JEKYLL_GITHUB_TOKEN='abc123def456'

Note: Replace the abc123def456 with your token.

Now reload the Terminal.

You can check the new environment variable with the following command line that should display your GitHub token.

echo $JEKYLL_GITHUB_TOKEN

In addition

For security reason you can also access GitHub token with the following command line while building or serving Jekyll website:

JEKYLL_GITHUB_TOKEN=abc123def456 bundle exec jekyll serve

Also you can set temporary environment variable with the following command line:

export JEKYLL_GITHUB_TOKEN=abc123def456

The export command run by itself and not contained within .bash_profile will only be a temporary setting and the environment variable will not persist unless you add it to the .bash_profile.

If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!

If this article has helped you solve the problem then please leave a comment :smiley:

Thanks for reading!