-
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
Make docs portable by using relative URLs #271
Comments
Hi @robons - thanks for raising this with us. Just to check my understanding - you'd like it so that when Middleman runs and builds the site, the generated files use relative urls throughout? Or is the issue something different? (By the way, we may add your comment to the similar issues you mentioned, then close this issue - just to help us avoid having duplicating issues. Hope that's ok.) |
Hi @robons - just checking if you saw my question above? ☝️ |
Ah, sorry I missed that. Thanks for your reply.
Yes, I think using relative URLs throughout would be helpful in that we can use it wherever it's stored without having to create a unique subdomain or run a local development server to view it.
I think this issue goes a bit beyond the other issues I've mentioned. I'd be happy for you to close this issue as long as it's clear what my suggested solution is on said issues. |
Thank you @robons! I'll keep this issue open as we're hoping to work on this and the related issues soon. |
@eddgrant has kindly put together a a reproduction case for the absolute links issue: https://github.com/hmrc/example-tech-docs-template-absolute-links |
This aims to address alphagov#271 by ensuring that all TOC links are generated as relative links, rather than absolute. The desired outcome being that the site no longer makes assumptions about being deployed at "/" which in turn makes it "portable" (i.e. possible to deploy it at an arbitrary path).
This aims to address alphagov#271 by ensuring that all TOC links are generated as relative links, rather than absolute. The desired outcome being that the site no longer makes assumptions about being deployed at "/" which in turn makes it "portable" (i.e. possible to deploy it at an arbitrary path).
This aims to address alphagov#271 by ensuring that all TOC links are generated as relative links, rather than absolute. The desired outcome being that the site no longer makes assumptions about being deployed at "/" which in turn makes it "portable" (i.e. possible to deploy it at an arbitrary path).
This aims to address alphagov#271 by ensuring that all TOC links are generated as relative links, rather than absolute. The desired outcome being that the site no longer makes assumptions about being deployed at "/" which in turn makes it "portable" (i.e. possible to deploy it at an arbitrary path).
Hey folks, I have been looking in to this a little, I thought it might be helpful to start building up a list of things which are affected by the use of relative paths. So far I have discovered that the following areas break when deploying a tech-docs site at a path other than
This is of course not an exhaustive list, just what I've noticed so far. I have tried out an approach to alter the ToC generation code to inspect the I'm starting to look at the search functionality now, but I'm yet to figure out how this works. I initially thought it submitted a GET request to Google's search API however I'm starting to think that there's some JavaScript cleverness involved that I don't yet fully understand. Hope that's of some use, I'm really keen to find a solution to this so if there's anything I can do to help please let me know. |
This aims to address alphagov#271 by ensuring that all TOC links are generated as relative links, rather than absolute. The desired outcome being that the site no longer makes assumptions about being deployed at "/" which in turn makes it "portable" (i.e. possible to deploy it at an arbitrary path).
Happy new year folks! Further to my last comment I believe I now have everything working when generating sites using relative links. This includes the search functionality for which I took inspiration from @digitalronin notes in alphagov/tech-docs-template#213. My changes are in the TRG-128 branch of our HMRC fork (diff against your master branch here). I'm keen to avoid running a long-lived fork, would you be open to a discussion about getting my changes reviewed and merged back in to your repository? I'd be happy to talk through them and make a plan via some sort of video meetup (Meet/ Zoom etc). Let me know your thoughts? Cheers, Edd |
Hi @eddgrant, sorry for the late reply, your changes look great! I'm happy to review the changes in the usual way, are you happy to raise a pull request? |
Hey @lfdebrux , no worries at all, thanks for getting back to me. Happy to raise a PR. Since my last message I've found a couple of other areas which are also affected when generating sites using relative links:
I've added fixes for them both in our branch, would you like me to submit a single PR containing all the fixes, or do them in a more piecemeal style with multiple PRs? Let me know your preference and I'll get the necessary bits and bobs raised. |
Thanks! A single PR would be great, if that's okay with you :) |
Absolutely, will get one raised. |
This aims to address alphagov#271 by ensuring that all TOC links are generated as relative links, rather than absolute. The desired outcome being that the site no longer makes assumptions about being deployed at "/" which in turn makes it "portable" (i.e. possible to deploy it at an arbitrary path).
Update on where we are this. Thanks to a big effort from @eddgrant, we have some code in the main branch that should let you use the Middleman relative links feature. See PR #291 for the gory details, but the short version is that you just need to add the following lines to
This covers the use case mentioned in this issue, and should also help with situations where a user is deploying to a service like GitHub Pages that has a prefix path. If anyone feels like testing this out and reporting back on this issue, that would be amazing! We're hoping to turn this into a proper release soon. |
I have a PR to add some release notes for this change, in #293. |
This issue has been 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). |
I'm testing out the use of the tech-docs for a project and I'm finding it difficult to use given the tool's expectations about where it's going to be placed on a server.
This issue is in the same vein as alphagov/tech-docs-template#213 and #196, however, I think it would be useful if the project could go a bit further than these suggestions.
It's often the case that people might want to host the same documentation in multiple places for ease of access, or even provide an offline version of said docs for users on air-gapped systems; for these reasons it's not always possible to know at build time exactly where the docs will end up being 'hosted'/stored. I don't believe the generated documentation should have these values baked into them. Ideally I'd like to be able to view and test the HTML docs on our continuous integration and know that the exact same files (without any URL changes) are deployed on 'production'.
I believe it would be much easier to make use of this template if the docs were built with zero knowledge of where they end up being deployed. This could be achieved by the use of relative URLs (think
./images/search-button.png
or../index.html
in the case of folders) when including an image, linking to a page inside the same project or using the search functionality.Unfortunately my team doesn't have the experience with ruby to make this a reality. Would it be possible for someone to implement this change?
The text was updated successfully, but these errors were encountered: