Skip to content
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

How to link a static HTML file not generated by Docusaurus #3894

Closed
ArtFlag opened this issue Dec 8, 2020 · 5 comments
Closed

How to link a static HTML file not generated by Docusaurus #3894

ArtFlag opened this issue Dec 8, 2020 · 5 comments
Labels
documentation The issue is related to the documentation of Docusaurus

Comments

@ArtFlag
Copy link
Contributor

ArtFlag commented Dec 8, 2020

📚 Documentation

The docs mention how to link to a page (js/md), a blog, etc, but not how to link to static HTML page that was not generated by Docusaurus.

Is there a way to do this?

Have you read the Contributing Guidelines on issues?

Yes

@ArtFlag ArtFlag added documentation The issue is related to the documentation of Docusaurus status: needs triage This issue has not been triaged by maintainers labels Dec 8, 2020
@slorber
Copy link
Collaborator

slorber commented Dec 8, 2020

Hi,

If you use an absolute url, it will use regular HTML server-side navigation (no html5 history.push() used by SPA routers).

For internal URLs that are not part of the SPA, for example a HTML page put in /static/myPage.html you can use the pathname:// protocol, like [myPage](pathname:///myPage) or <Link to="pathname:///myPage">

The pathname:// protocol is not documented on purpose as it's an escape hatch. It's not a std solution and I'm not sure yet it's the final API we want to use to solve this usecase.

Does it answer your question?

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Dec 8, 2020
@ArtFlag
Copy link
Contributor Author

ArtFlag commented Dec 8, 2020

Yes, thanks a lot!

@henrycity
Copy link

pathname:// protocol

I am not sure if I get what you mean. I am trying to serve a static website with docusaurus and the file path is /static/admin/index.html. What should I do in this case?

I want the admin/index.html to load when I try to navigate to https://mywebsite.com/admin.

@slorber
Copy link
Collaborator

slorber commented Sep 1, 2021

@henrycity

I am not sure if I get what you mean. I am trying to serve a static website with docusaurus and the file path is /static/admin/index.html. What should I do in this case?
I want the admin/index.html to load when I try to navigate to https://mywebsite.com/admin.

You don't have to do anything in principle, this should work automatically for most hosting solutions and is not really related to Docusaurus. Docusaurus is only responsible for creating HTML files, not serving them.

Docusaurus copies website/static/admin/index.html to website/build/admin/index.html

We provide docusaurus serve for convenience, and it would serve website/build/admin/index.html at /admin. Other hosting solutions should have similar behavior, and might eventually add an extra trailing slash (take a look at https://github.com/slorber/trailing-slash-guide).


We have an example in production on a test page here:


Now if you want all routes /admin/* to serve /admin/index.html, this is a totally different story, and you'll have to configure rewrite rules on your host (each has a different config to do so, and you'll have to refer to their doc).

On Netlify it would require using a _redirects file with a rule like:

/admin/*         /admin           200

@henrycity
Copy link

@henrycity

I am not sure if I get what you mean. I am trying to serve a static website with docusaurus and the file path is /static/admin/index.html. What should I do in this case?
I want the admin/index.html to load when I try to navigate to https://mywebsite.com/admin.

You don't have to do anything in principle, this should work automatically for most hosting solutions and is not really related to Docusaurus. Docusaurus is only responsible for creating HTML files, not serving them.

Docusaurus copies website/static/admin/index.html to website/build/admin/index.html

We provide docusaurus serve for convenience, and it would serve website/build/admin/index.html at /admin. Other hosting solutions should have similar behavior, and might eventually add an extra trailing slash (take a look at https://github.com/slorber/trailing-slash-guide).

We have an example in production on a test page here:

Now if you want all routes /admin/* to serve /admin/index.html, this is a totally different story, and you'll have to configure rewrite rules on your host (each has a different config to do so, and you'll have to refer to their doc).

On Netlify it would require using a _redirects file with a rule like:

/admin/*         /admin           200

Thanks for the detailed answer. I actually use AWS S3 to host it and manage to deploy it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation The issue is related to the documentation of Docusaurus
Projects
None yet
Development

No branches or pull requests

3 participants