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:
Step 1. Create the GitHub personal access token with
public_repo scope. You can find guide here.
Note: Remember to keep the token secret - you don’t want other people to use the API on your behalf!
Step 2. Open the
~/.bash_profile file (you can use your favorite text editor instead of
nano if you’d like).
Note: This file may have different names and locations depending on your shell and OS. For example:
.zshenv. In MacOS is a
.bash_profilethat 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.
Step 3. 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:
Note: Replace the
abc123def456with your token.
Step 4. Now reload the Terminal.
You can check the new environment variable with the following command line that should display your GitHub token.
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 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