Netlify has been trending recently with its offerings of free static site hosting with CI-like continuous deployment and automatic https configuration. However Netlify [does not support deploying site to a subdirectory]. The workaround is to setup rewrite rules.
Recently, I wanted to make this blog fully available on xiamx.me via netlify, but encountered a issue while trying to deploy the site to netlify. Originally this blog is available under the subdirectory
cs.mcgill.ca. Historically, when shared web hosting were still popular, each system user on
cs.mcgill.ca would be able to host their site inside their
$HOME/public_html directory, and their public url will be
http://hostname/~username. With containers and modern web deployments, this style is no longer popular.
cs.mcgill.ca/~mxia3 style of website root directory, hexo was configured to generate links relative to the root
~mxia3 with the folliwng
# Hexo Configuration
However Netlify does not support subdirectory site deployment. And when the site is deployed to the root of https://xiamx.me, many links fail to work. For example
~mxia3 subdirectory is not present under
A workaround to this is to add proxy rules by creating
netlify.toml file under the root directory of the project with content like the following:
This redirect rule turns every
/~mxia3/* url into requesting the resource directly in the root direcotry
/ so that a request to
https://xiamx.me/~mxia3/2019/02/24/Using-gRPC-in-Production/ is proxied to
https://xiamx.me/2019/02/24/Using-gRPC-in-Production/ behind the scene.