Skip to content

Commit 1ecc94f

Browse files
committed
docs(book): 📝 added docs for relative path deployment
1 parent cf60c12 commit 1ecc94f

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

docs/0.3.x/en-US/SUMMARY.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- [Request State](/docs/strategies/request-state)
2929
- [Revalidation](/docs/strategies/revalidation)
3030
- [Incremental Generation](/docs/strategies/incremental)
31-
- [State Amalgamation](/docs/strategies/amalgamation)
31+
- [State Amalgamation](/docs/strategies/amlagamation)
3232
- [CLI](/docs/cli)
3333
- [Ejecting](/docs/ejecting)
3434
- [Testing](/docs/testing/intro)
@@ -42,6 +42,7 @@
4242
- [Server Deployment](/docs/deploying/serverful)
4343
- [Serverless Deployment](/docs/deploying/serverless)
4444
- [Optimizing Code Size](/docs/deploying/size)
45+
- [Relative Paths](/docs/deploying/relative-paths)
4546
- [Migrating from v0.2.x](/docs/updating)
4647

4748
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Deploying to Relative Paths
2+
3+
There are many instances where you'll want to deploy a Perseus website not to the root of a domain (e.g. <https://arctic-hen7.github.io>) but to a relative path under it (e.g. <https://arctic-hen7.github.io/perseus>). This is difficult because Perseus expects all its internal assets (under the URL `/.perseus`) to be at the root of the domain. However, this is easily solved with the `PERSEUS_BASE_PATH` environment variable, which you should set to be the full URL you intend to deploy your app at.
4+
5+
For example, if we wanted to deploy an existing app to the URL <https://arctic-hen7.github.io/perseus> (where you're reading this right now), we'd set `PERSEUS_BASE_PATH=https://arctic-hen7.github.io/perseus` before running `perseus export` (note that relative path prefixing is designed for exported apps, though it could be used for apps run with `perseus serve` as well in theory). This will tell Perseus where to expect things to be, and it will also automatically set your apps _base URI_ with the HTML `<base>` tag (if you're familiar with this, don't worry about trailing slashes, Perseus does this for you).
6+
7+
## Code Changes
8+
9+
If you want to deploy a Perseus app to a relative path, the only code changes you need to make are to your links, which should be made _relative_ rather than _absolute_. For example, you linked to `/about` before, now you would link to `about`. Don't worry about doing this, because the HTML `<base>` tag is designed to prepend your base path to this automatically, effectively turning your relative path into an absolute one. You can read more about this [on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base).

docs/next/en-US/SUMMARY.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Summary
1+
# Introduction
22

33
- [Introduction](/docs/intro)
44
- [What is Perseus?](/docs/what-is-perseus)
@@ -42,6 +42,7 @@
4242
- [Server Deployment](/docs/deploying/serverful)
4343
- [Serverless Deployment](/docs/deploying/serverless)
4444
- [Optimizing Code Size](/docs/deploying/size)
45+
- [Relative Paths](/docs/deploying/relative-paths)
4546
- [Migrating from v0.2.x](/docs/updating)
4647

4748
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Deploying to Relative Paths
2+
3+
There are many instances where you'll want to deploy a Perseus website not to the root of a domain (e.g. <https://arctic-hen7.github.io>) but to a relative path under it (e.g. <https://arctic-hen7.github.io/perseus>). This is difficult because Perseus expects all its internal assets (under the URL `/.perseus`) to be at the root of the domain. However, this is easily solved with the `PERSEUS_BASE_PATH` environment variable, which you should set to be the full URL you intend to deploy your app at.
4+
5+
For example, if we wanted to deploy an existing app to the URL <https://arctic-hen7.github.io/perseus> (where you're reading this right now), we'd set `PERSEUS_BASE_PATH=https://arctic-hen7.github.io/perseus` before running `perseus export` (note that relative path prefixing is designed for exported apps, though it could be used for apps run with `perseus serve` as well in theory). This will tell Perseus where to expect things to be, and it will also automatically set your apps _base URI_ with the HTML `<base>` tag (if you're familiar with this, don't worry about trailing slashes, Perseus does this for you).
6+
7+
## Code Changes
8+
9+
If you want to deploy a Perseus app to a relative path, the only code changes you need to make are to your links, which should be made _relative_ rather than _absolute_. For example, you linked to `/about` before, now you would link to `about`. Don't worry about doing this, because the HTML `<base>` tag is designed to prepend your base path to this automatically, effectively turning your relative path into an absolute one. You can read more about this [on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base).

0 commit comments

Comments
 (0)