Open rmannibucau opened 1 week ago
This issue pops obviously for pages not stored in the URL path folder. A common example is 404.html
I've tested Rewriting 404.html file on deploying GitHub Pages
approach.
And it seems to works as expected.
PowerShell steps to rewrite HTML https://github.com/filzrev/docfx_sample_404_notfound/blob/main/.github/workflows/build_docs.yml#L78C1-L93C47
Sample 404.md
file that simulate default 404: NotFound page
https://raw.githubusercontent.com/filzrev/docfx_sample_404_notfound/main/docs/404.md
Sample render result page https://filzrev.github.io/docfx_sample_404_notfound/foo/bar/whatever/not/existing
Is there other scenario that needs Root relative URL? If there is such a requirements, I thought it need to add following features.
<base href="/{baseURL}/" />
tag inside <head>
tag.@filzrev <base>
is a workaround indeed but it has side effects (in particular when embedding js in pages) so it is always better to avoid it. Indeed a custom implementation will make it work, this is why this issue is about ensuring default generation is compatible with common frontend middleware error page mapping without redirection hacks or breaking the site js.
<base>
is a workaround indeed but it has side effects (in particular when embedding js in pages) so it is always better to avoid it.
I agree with that opinion. I've using <base>
tag for 404 page thought.
It should be avoided for general purpose usage.
this is why this issue is about ensuring default generation is compatible with common frontend middleware error page mapping without redirection hacks or breaking the site js.
This issue title states SystemMetadataGenerator should use absolute path.
Though, Is there any problems when using custom HtmlPostProcessor
approach?
I though it seems can be implemented as custom PostProcessor that rewrite related urls.
@filzrev no issue to impl it differently. My reasoning was : generate it right, but a "fix it after works" too even if I will not hide I dont fully get why it is better it would do the job so no issue for me. Only key point: no dev needed for end user.
I've tested Custom HTML PostProcessor approach at this branch
UrlRewritePostProcessor rewrite HTML relative URLs to specified Absolute URL
or Site Relative URL
.
The problems that can be raised are.
404.md
)docfx serve
command when using URL rewriting feature.It might be better approach, Simply rewrite HTMLs on site deployment timing.
Eactly, this is why I thought about ensuring the generator is able to generate an error-free website instead of relying on relative links which can be broken by globbing rewrite rules.
What I don't get quite well right now is why you don't want to generate the website with absolute links if url is set in the docfx.json? Any technical blocker from your point of view?
Is your feature request related to a problem? Please describe. I want any asset or page to use absolute links from the root of the website (to be configured in this mode). Goal is to be able to configure the base of the website on github pages (or any similar system). Instead of having for subfolders something like
../../public/docfx.min.js
I'd like to get/myproject/public/docfx.min.js
and so on.This issue pops obviously for pages not stored in the URL path folder. A common example is
404.html
- created from404.md
- which will be served when hitting/myproject/foo/bar/whatever/not/existing
.Describe the solution you'd like Ideally I'd like to put in header metadata on
404.md
a flag to use absolute path for this page - but if global for all pages I'm happy too.Describe alternatives you've considered For now I added a js script in the page to redirect on the actual 404 page url when the subfolder is not matching the hosting but this changes the url and is not satisfying.