This guide explains how to host your documentation site using the Just the Docs Jekyll theme in an existing repository.
Copy the template files to your repository
- Clone just-the-docs template repository or download the template files as a ZIP archive and extract them.
- Create a
.github/workflowsdirectory at your project root if your repo doesn’t already have one. - Copy the
pages.ymlfile from thejust-the-docs-template/.github/workflowsdirectory to your repository’s.github/workflowsdirectory. - Create new folder named
docsin the root of your repository. - Copy all remaining template files to the
docsfolder.
Building and previewing your site locally
Assuming Jekyll and Bundler are installed on your computer:
- Change your working directory to the root directory of your site.
- Run
bundle install. - Run
bundle exec jekyll serveto build your site and preview it atlocalhost:4000.
Update the pages.yml workflow to build and deploy your site from the docs folder
- Open the
pages.ymlfile in your repository’s.github/workflowsdirectory. -
Set the default
working-directoryparam for the build job.build: runs-on: ubuntu-latest defaults: run: working-directory: docs -
Set the
working-directoryparam for the Setup Ruby step.- name: Setup Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '3.3' bundler-cache: true cache-version: 0 working-directory: '$/docs' -
Set the path param for the Upload artifact step:
- name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: docs/_site/ -
Modify the trigger so that only changes within the
docsdirectory start the workflow. Otherwise, every change to your project (even those that don’t affect the docs) would trigger a new site build and deploy.on: push: branches: - "main" paths: - "docs/**" - Configure the publishing source for your GitHub Pages site to
GitHub Actionsin the repository settings.
Licensing and Attribution
When a repository contains code from multiple sources with different copyright holders, you should:
- Preserve all original license files and attributions from each source.
- Clearly indicate in your main README or a dedicated NOTICE/ATTRIBUTION file which parts of the repository come from which source, and under what license.
- Do not remove or alter the copyright/license headers in the original files.
- If you modify code from either source, note your changes and the date in the relevant files or in your attribution file