github_pages.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. .. _github_pages:
  2. =======================
  3. Hosting on GitHub Pages
  4. =======================
  5. You use `GitHub Pages <github_pages_website_>`_ to host documentation generated by ``sphinx-multiversion``.
  6. Setting up the ``gh-pages`` Branch
  7. ==================================
  8. First, you need to create a ``gh-pages`` branch and disable Jekyll.
  9. .. code-block:: bash
  10. git checkout --orphan gh-pages
  11. touch .nojekyll
  12. git add .nojekyll
  13. git commit -m "Disable Jekyll"
  14. Then, switch back to the branch you were on and build the documentation using ``sphinx-multiversion``:
  15. .. code-block:: bash
  16. mkdir html
  17. sphinx-multiversion docs/ html/
  18. If everything worked fine, you now need to switch back to your ``gh-pages`` branch and commit the data there:
  19. .. code-block:: bash
  20. git checkout gh-pages
  21. for dirname in html/*; do mv "html/$dirname" "$dirname" && git add "$dirname"; done
  22. git commit -m "Added HTML docs"
  23. git push origin gh-pages
  24. Now your documentation should already be online.
  25. You can navigate to ``https://username.github.io/reponame/master/`` to see the documentation for the master branch.
  26. Redirecting from the Document Root
  27. ==================================
  28. You can easily redirect users that type ``https://username.github.io/reponame/`` into their addressbar to the documentation for any version you like.
  29. Just add a :file:`index.html` file to the root directory of your ``gh-pages`` branch:
  30. .. code-block:: html
  31. <!DOCTYPE html>
  32. <html>
  33. <head>
  34. <title>Redirecting to master branch</title>
  35. <meta charset="utf-8">
  36. <meta http-equiv="refresh" content="0; url=./master/">
  37. <link rel="canonical" href="https://username.github.io/reponame/master/">
  38. </head>
  39. </html>
  40. .. _github_pages_website: https://pages.github.com/