As the subject says, I'd like to have my custom domain redirect to a specific project's gh-pages branch.
I can easily get the standard behaviour:
But I cannot figure out how to get this:
I very much appreciate pointers.
On your site's repository, click the settings tab . Under custom domain, type your custom domain and save. GitHub will automatically create a commit with a CNAME file at the root of your repository. Visit the dashboard provided by your domain provider and add a CNAME record pointing to your subdomain.
You can customize the domain name of your GitHub Pages site. GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.
The redirect is accomplished with a <meta> tag. By setting the http-equiv attribute to refresh and the content attribute to 0; URL=https://example.com/ we will redirect the user to 'https://example.com/'.
If your custom.domain.tld
currently points to username.github.io
, you'll need to remove the CNAME file from your user.github.io
repository's Master branch. Then, add the same CNAME
file (with contents custom.domain.tld
) to your Project repository's gh-pages branch. If you've already set up DNS properly for your user.github.io
repository, then you won't need to make any changes there, the new CNAME settings on GitHub will take care of it.
One note: when you assign a custom domain (eg custom1.domain.tld) to a User Pages repository, all Project Pages in that User's account will inherit their respective custom1.domain.tld/project
address, as well as any directly assigned domain (eg custom2.domain.tld).
For example, I have:
More in GitHub's Setting up a custom domain with Pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With