9.7 KiB
title, intro, redirect_from, product, versions, topics, shortTitle
| title | intro | redirect_from | product | versions | topics | shortTitle | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Managing a custom domain for your GitHub Pages site | You can set up or update certain DNS records and your repository settings to point the default domain for your {% data variables.product.prodname_pages %} site to a custom domain. |
|
{% data reusables.gated-features.pages %} |
|
|
Manage a custom domain |
People with admin permissions for a repository can configure a custom domain for a {% data variables.product.prodname_pages %} site.
About custom domain configuration
Make sure you add your custom domain to your {% data variables.product.prodname_pages %} site before configuring your custom domain with your DNS provider. Configuring your custom domain with your DNS provider without adding your custom domain to {% data variables.product.product_name %} could result in someone else being able to host a site on one of your subdomains.
{% windows %}
The dig command, which can be used to verify correct configuration of DNS records, is not included in Windows. Before you can verify that your DNS records are configured correctly, you must install BIND.
{% endwindows %}
{% note %}
Note: DNS changes can take up to 24 hours to propagate.
{% endnote %}
Configuring a subdomain
To set up a www or custom subdomain, such as www.example.com or blog.example.com, you must add your domain in the repository settings. After that, configure a CNAME record with your DNS provider.
{% data reusables.pages.navigate-site-repo %} {% data reusables.repositories.sidebar-settings %} {% data reusables.pages.sidebar-pages %}
-
Under "Custom domain", type your custom domain, then click Save. If you are publishing your site from a branch, this will create a commit that adds a
CNAMEfile to the root of your source branch. If you are publishing your site with a custom {% data variables.product.prodname_actions %} workflow , noCNAMEfile is created. For more information about your publishing source, see "AUTOTITLE."{% note %}
Note: If your custom domain is an internationalized domain name, you must enter the Punycode encoded version.
For more information on Punycodes, see Internationalized domain name.
{% endnote %}
-
Navigate to your DNS provider and create a
CNAMErecord that points your subdomain to the default domain for your site. For example, if you want to use the subdomainwww.example.comfor your user site, create aCNAMErecord that pointswww.example.comto<user>.github.io. If you want to use the subdomainanother.example.comfor your organization site, create aCNAMErecord that pointsanother.example.comto<organization>.github.io. TheCNAMErecord should always point to<user>.github.ioor<organization>.github.io, excluding the repository name. {% data reusables.pages.contact-dns-provider %} {% data reusables.pages.default-domain-information %}
{% indented_data_reference reusables.pages.wildcard-dns-warning spaces=3 %} {% data reusables.command_line.open_the_multi_os_terminal %}
-
To confirm that your DNS record configured correctly, use the
digcommand, replacing WWW.EXAMPLE.COM with your subdomain.$ dig WWW.EXAMPLE.COM +nostats +nocomments +nocmd > ;WWW.EXAMPLE.COM. IN A > WWW.EXAMPLE.COM. 3592 IN CNAME YOUR-USERNAME.github.io. > YOUR-USERNAME.github.io. 43192 IN CNAME GITHUB-PAGES-SERVER . > GITHUB-PAGES-SERVER . 22 IN A 192.0.2.1
{% data reusables.pages.build-locally-download-cname %} {% data reusables.pages.enforce-https-custom-domain %}
Configuring an apex domain
To set up an apex domain, such as example.com, you must configure a custom domain in your repository settings and at least one ALIAS, ANAME, or A record with your DNS provider.
{% data reusables.pages.www-and-apex-domain-recommendation %} For more information, see "Configuring a subdomain."
{% data reusables.pages.navigate-site-repo %} {% data reusables.repositories.sidebar-settings %} {% data reusables.pages.sidebar-pages %}
- Under "Custom domain", type your custom domain, then click Save. If you are publishing your site from a branch, this will create a commit that adds a
CNAMEfile to the root of your source branch. If you are publishing your site with a custom {% data variables.product.prodname_actions %} workflow , noCNAMEfile is created. For more information about your publishing source, see "AUTOTITLE." - Navigate to your DNS provider and create either an
ALIAS,ANAME, orArecord. You can also createAAAArecords for IPv6 support. If you're implementing IPv6 support, we highly recommend using anArecord in addition to yourAAAArecord, due to slow adoption of IPv6 globally. {% data reusables.pages.contact-dns-provider %}- To create an
ALIASorANAMErecord, point your apex domain to the default domain for your site. {% data reusables.pages.default-domain-information %} - To create
Arecords, point your apex domain to the IP addresses for {% data variables.product.prodname_pages %}.185.199.108.153 185.199.109.153 185.199.110.153 185.199.111.153 - To create
AAAArecords, point your apex domain to the IP addresses for {% data variables.product.prodname_pages %}.2606:50c0:8000::153 2606:50c0:8001::153 2606:50c0:8002::153 2606:50c0:8003::153
- To create an
{% indented_data_reference reusables.pages.wildcard-dns-warning spaces=3 %} {% data reusables.command_line.open_the_multi_os_terminal %}
- To confirm that your DNS record configured correctly, use the
digcommand, replacing EXAMPLE.COM with your apex domain. Confirm that the results match the IP addresses for {% data variables.product.prodname_pages %} above.-
For
Arecords:$ dig EXAMPLE.COM +noall +answer -t A > EXAMPLE.COM 3600 IN A 185.199.108.153 > EXAMPLE.COM 3600 IN A 185.199.109.153 > EXAMPLE.COM 3600 IN A 185.199.110.153 > EXAMPLE.COM 3600 IN A 185.199.111.153 -
For
AAAArecords:$ dig EXAMPLE.COM +noall +answer -t AAAA > EXAMPLE.COM 3600 IN AAAA 2606:50c0:8000::153 > EXAMPLE.COM 3600 IN AAAA 2606:50c0:8001::153 > EXAMPLE.COM 3600 IN AAAA 2606:50c0:8002::153 > EXAMPLE.COM 3600 IN AAAA 2606:50c0:8003::153Remember to also check your
Arecord. {% data reusables.pages.build-locally-download-cname %} {% data reusables.pages.enforce-https-custom-domain %}
-
Configuring an apex domain and the www subdomain variant
When using an apex domain, we recommend configuring your {% data variables.product.prodname_pages %} site to host content at both the apex domain and that domain's www subdomain variant.
To set up a www subdomain alongside the apex domain, you must first configure an apex domain by creating an ALIAS, ANAME, or A record with your DNS provider. For more information, see "Configuring an apex domain."
After you configure the apex domain, you must configure a CNAME record with your DNS provider.
-
Navigate to your DNS provider and create a
CNAMErecord that pointswww.example.comto the default domain for your site:<user>.github.ioor<organization>.github.io. Do not include the repository name. {% data reusables.pages.contact-dns-provider %} {% data reusables.pages.default-domain-information %} -
To confirm that your DNS record configured correctly, use the
digcommand, replacing WWW.EXAMPLE.COM with yourwwwsubdomain variant.$ dig WWW.EXAMPLE.COM +nostats +nocomments +nocmd > ;WWW.EXAMPLE.COM IN A > WWW.EXAMPLE.COM. 3592 IN CNAME YOUR-USERNAME.github.io. > YOUR-USERNAME.github.io. 43192 IN CNAME GITHUB-PAGES-SERVER. > GITHUB-PAGES-SERVER. 22 IN A 192.0.2.1
Removing a custom domain
If you get an error about a custom domain being taken, you may need to remove the custom domain from another repository.
{% data reusables.pages.navigate-site-repo %} {% data reusables.repositories.sidebar-settings %} {% data reusables.pages.sidebar-pages %}
Securing your custom domain
{% data reusables.pages.secure-your-domain %} For more information, see "AUTOTITLE."
