-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable publishing via github pages, without requiring a dedicated domain name #191
Comments
Thank you for raising this with us @digitalronin. I'll pass this along to the team that's identifying possible fixes and improvements to the Tech Docs Template at the moment, as they should have GitHub Pages integration on their radar from your previous issue (https://github.com/alphagov/tdt-documentation/issues/67). |
These files represent the patches described in this issue: alphagov/tech-docs-gem#191 They enable using (a patched version of) the gov.uk tech-docs gem to publish a documentation site using github pages without requiring the site to be published at the root docpath ("/") of a dedicated domain. i.e. this enables publishing a site at: ``` https://username.github.io/my-repo ``` This is the default github pages URL for the repository "my-repo" belonging to the github user/organisation "username". As opposed to: ``` https://my.custom.domain/ ``` Without these patches, the search function of the site will not work correctly. The patch files in this directory are used in the Dockerfile to build the docker image which is used in the publishing process. This is a nasty hack, but the alternative is to maintain forks of two gems, `govuk_tech_docs` and `middleman-search-gds`, so this seems a pragmatic solution until the issue above is resolved in the upstream gems.
FYI, I created this template repository for teams who want to create github pages documentation sites using the tech-docs template: |
We're using the I've opened a PR here which fixes the search issue: #196 There are 2-3 other asset-path related issues, relating to our use of Middleman's |
I think for this to work fully we also want a way to add the http prefix to the GOV.UK Frontend assets path: PR #292 should help with that. |
This issue may be fixed in release v3.2.0. You can now configure your Tech Docs Template (TDT) to build your documentation site to use relative links to pages and assets. Thanks @eddgrant for contributing this feature and the associated fixes. This change was introduced in pull request #291: Support sites deployed on paths other than "/" (by generating relative links). |
We use the tech-docs gem at the MoJ for some of our documentation sites, e.g.
Both of those are published via github pages, with dedicated domain names.
It would be good if we could publish tech-docs sites using github pages without needing a separate domain name for each site, and just using the "default" URL from github pages, e.g. https://ministryofjustice.github.io/technical-guidance/
The search feature of the tech-docs gem, which is something we find extremely useful, doesn't work by default, because of some baked-in assumptions:
/
plus the relative path to the filesearch.json
when carrying out a search is hard-coded to/search.json
Both of these could be fixed by changes to two gems:
In
govuk_tech_docs-2.0.13/lib/assets/javascripts/_modules/search.js
:search.js.erb
and change line 37 from:to
The switch to ".erb" causes sprockets pre-process the file using erb when creating the application.js file, so setting ROOT_DOCPATH to "/technical-guidance" means the search function can download the JSON data when the site is published.
In
middleman-search-gds-0.11.1/lib/middleman-search/search-index-resource.rb
add a new line around line 116:This prefixes every document url with the docpath, so that the search results render links that point to the right place to view the target document.
As long as ROOT_DOCPATH is unset when running
middleman server
, the local preview works fine. ROOT_DOCPATH just needs to be set when runningmiddleman build
.It would be nicer if I could pass ROOT_DOCPATH from
config/tech-docs.yml
down to the relevant parts of both gems, but I couldn't figure out how to do that.These changes are to two separate gems, which is why I haven't raised a PR - neither change makes sense without the other, and I'm not entirely happy about the hacky way this works, or adding a dependency on an environment variable.
I'm probably going to create a docker image that uses patched versions of the gems to allow us to do what we need to publish our documentation via github pages, but I hope you'll consider making these (or preferably less hacky) changes to allow publishing sites which are not hosted at the root docpath of the relevant domains.
I think the ability to use default github pages publishing makes it a lot easier for people to get their documentation sites up and running, and could lead to more teams being able to benefit from this gem - the search feature is a real game-changer.
The text was updated successfully, but these errors were encountered: