I am using Github Pages and Netlify to host my site. It is a static site that uses Gatsby. I also am using a custom domain. Everything works fine for the main site. Index and all the other pages display as expected.
However, I have other repos that use github pages, that I set to also use my domain. When the link is clicked to open the project page, it instead goes to my websites 404 page. When I use the default url that github pages gives the website for the project loads fine.
There are some ways to solve this, but depend on your use case and the way you want to feed up your links.
Have your GitHub pages subdomain for the pages
CNAME
mysub.example.com
Make a CNAME
entry in your DNS for the mysub
name and give it a value of YOUR-GITHUB-USERNAME.github.io
replacing YOUR-GITHUB-USERNAME
with your username on github.
Include a _redirects
file to the root of your build folder for Netlify to serve up the path(s) you want to proxy
.
_redirects
/mysub/* https://username.github.io/:splat 200!
NOTE : In Gatsby, you place the redirects in static/_redirects
. If you are using the gatsby-plugin-netlify
in your Gatsby project, you could optionally setup the above in that configuration ( see readme ), but the above is still compatible.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.