You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

github-pages.md 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. +++
  2. title = "GitHub Pages"
  3. weight = 30
  4. +++
  5. By default, GitHub Pages uses Jekyll (A ruby based static site generator),
  6. but you can use whatever you want provided you have an `index.html` file in the root of a branch called `gh-pages`.
  7. That branch name can also be manually changed in the settings of a repository.
  8. We are going to use [TravisCI](https://travis-ci.org) to automatically publish the site. If you are not using Travis already,
  9. you will need to login with the GitHub OAuth and activate Travis for the repository.
  10. Don't forget to also check if your repository allows GitHub Pages in its settings.
  11. ## Ensure Travis can access your theme
  12. Depending on how you added your theme Travis may not exactly know how to access
  13. it. The best way to ensure it will have full access to the theme is to use git
  14. submodules. When doing this ensure you are using the `https` version of the URL.
  15. ```shell
  16. $ git submodule add {THEME_URL} themes/{THEME_NAME}
  17. ```
  18. ## Allowing Travis to push to GitHub
  19. Before pushing anything, Travis needs a Github private access key in order to make changes to your repository.
  20. If you're already logged in to your account, just click [here](https://github.com/settings/tokens) to go to your tokens page.
  21. Otherwise, navigate to `Settings > Developer Settings > Personal Access Tokens`.
  22. Generate a new token, and give it any description you'd like.
  23. Under the "Select Scopes" section, give it repo permissions. Click "Generate token" to finish up.
  24. Your token will now be visible!
  25. Copy it into your clipboard and head back to Travis.
  26. Once on Travis, click on your project, and navigate to "Settings". Scroll down to "Environment Variables" and input a name of `GH_TOKEN` with a value of your access token.
  27. Make sure "Display value in build log" is off, and then click add. Now Travis has access to your repository.
  28. ## Setting up Travis
  29. We're almost done. We just need some scripts in a .travis.yml file to tell Travis what to do.
  30. ```yaml
  31. before_script:
  32. # Download and unzip the gutenberg executable
  33. # Replace the version numbers in the URL by the version you want to use
  34. - curl -s -L https://github.com/Keats/gutenberg/releases/download/v0.3.1/gutenberg-v0.3.1-x86_64-unknown-linux-gnu.tar.gz | sudo tar xvzf - -C /usr/local/bin
  35. script:
  36. - gutenberg build
  37. # If you are using a different folder than `public` for the output directory, you will
  38. # need to change the `gutenberg` command and the `ghp-import` path
  39. after_success: |
  40. [ $TRAVIS_BRANCH = master ] &&
  41. [ $TRAVIS_PULL_REQUEST = false ] &&
  42. gutenberg build &&
  43. sudo pip install ghp-import &&
  44. ghp-import -n public &&
  45. git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
  46. ```
  47. If your site is using a custom domain, you will need to mention it in the `ghp-import` command: `ghp-import -c vaporsoft.net -n public`
  48. for example.
  49. Credits: this page is based on the article https://vaporsoft.net/publishing-gutenberg-to-github/