Putting your Swish Blog on a Subdirectory
Using a subdirectory (also called subfolder) for your blog can be good for SEO. So naturally, this is something that Swish supports, although it requires some advanced configuration.
We are using
/blog
as the subdirectory in this documentation, but you can choose anything else.
Perform the following steps:
- Add a custom domain.
- Add the directory as part of the custom domain, for example, in the the custom domain field, enter
example.com/blog
. - Set up a proxy to forward all request from the
/blog
subdirectory tohttp://BLOG_ID.i.swish.ink
.
You can see the ID of a blog on the blog listing page. - In the proxy configuration, add a header
X-Swish-Host
which will be the custom domain without the subdirectory. e.g.example.com
notexample.com/blog
.
Examples
With Nginx
In your configuration file:
server {
listen 80;
listen [::]:80;
server_name YOUR_BLOG_DOMAIN;
location /blog/ {
proxy_pass http://BLOG_ID.i.swish.ink;
proxy_set_header X-Swish-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
With Netlify
In netlify.toml
:
[[redirects]]
from = "/blog/*"
to = "https://YOUR_BLOG_ID.i.swish.ink/blog/:splat"
status = 200
force = true
headers = {X-Swish-Host = "YOUR_BLOG_DOMAIN"}
See Also
Demo
Check out the Demo to see how everything works without having to sign up.