Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.

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 Páginas de GitHub site to a custom domain.

Páginas de GitHub se encuentra disponible en repositorios públicos con GitHub gratis y en repositorios privados y públicos con GitHub Pro, Equipo de GitHub, Nube de GitHub Enterprise y Servidor de GitHub Enterprise. Para obtener más información, consulta "Productos de GitHub."

People with admin permissions for a repository can configure a custom domain for a Páginas de GitHub site.

En este artículo

About custom domain configuration

Make sure you add your custom domain to your Páginas de GitHub site before configuring your custom domain with your DNS provider. Configuring your custom domain with your DNS provider without adding your custom domain to GitHub could result in someone else being able to host a site on one of your subdomains.

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.

Note: DNS changes can take up to 24 hours to propagate.

Configuring a subdomain

To set up a www or custom subdomain, such as www.example.com or blog.example.com, you must create a CNAME file in your site's repository and configure a CNAME record with your DNS provider.

  1. On GitHub, navigate to your site's repository.

  2. En el nombre de tu repositorio, haz clic en Parámetros.

    Botón Parámetros del repositorio

  3. Under "Custom domain", type your custom domain, then click Save. This will create a commit that adds a CNAME file in the root of your publishing source.

    Save custom domain button

  4. Navigate to your DNS provider and create a CNAME record that points your subdomain to the default domain for your site. For example, if you want to use the subdomain www.example.com for your user site, create a CNAME record that points www.example.com to <user>.github.io. For more information about how to create the correct record, see your DNS provider's documentation. For more information about the default domain for your site, see "About Páginas de GitHub."

  5. Abre el terminal TerminalTerminalGit Bash.

  6. To confirm that your DNS record configured correctly, use the dig command, 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
  7. If you use a static site generator to build your site locally and push the generated files to GitHub, pull the commit that added the CNAME file to your local repository. For more information, see "Troubleshooting custom domains and Páginas de GitHub."

  8. Optionally, to enable HTTPS encryption for your site, select Enforce HTTPS. It can take up to 24 hours before this option is available. For more information, see "Securing your Páginas de GitHub site with HTTPS."

    Enforce HTTPS for custom domains option

Configuring an apex domain

To set up an apex domain, such as example.com, you must configure a CNAME file in your Páginas de GitHub repository and an ALIAS, ANAME, or A record with your DNS provider.

If you are using an apex domain as your custom domain, we recommend also setting up a www subdomain. If you configure the correct records for each domain type through your DNS provider, Páginas de GitHub will automatically create redirects between the domains. For example, if you configure www.example.com as your custom domain for your site, and you have ALIAS and CNAME records set up for the www and apex domains, then example.com will redirect to www.example.com. For more information, see "Managing a custom domain for your Páginas de GitHub site."

  1. On GitHub, navigate to your site's repository.

  2. En el nombre de tu repositorio, haz clic en Parámetros.

    Botón Parámetros del repositorio

  3. Under "Custom domain", type your custom domain, then click Save. This will create a commit that adds a CNAME file in the root of your publishing source.

    Save custom domain button

  4. Navigate to your DNS provider and create either an ALIAS, ANAME, or A record. For more information about how to create the correct record, see your DNS provider's documentation.

    • To create an ALIAS or ANAME record, point your apex domain to the default domain for your site. For more information about the default domain for your site, see "About Páginas de GitHub."

    • To create an A record, point your apex domain to the IP addresses for Páginas de GitHub.

      185.199.108.153
      185.199.109.153
      185.199.110.153
      185.199.111.153
  5. Abre el terminal TerminalTerminalGit Bash.

  6. To confirm that your DNS record configured correctly, use the dig command, replacing EXAMPLE.COM with your apex domain. Confirm that the results match the IP addresses for Páginas de GitHub above.

    $ dig EXAMPLE.COM +noall +answer
    > EXAMPLE.COM     3600    IN A     185.199.108.153
    > EXAMPLE.COM     3600    IN A     185.199.110.153
    > EXAMPLE.COM     3600    IN A     185.199.110.153
    > EXAMPLE.COM     3600    IN A     185.199.111.153
  7. If you use a static site generator to build your site locally and push the generated files to GitHub, pull the commit that added the CNAME file to your local repository. For more information, see "Troubleshooting custom domains and Páginas de GitHub."

  8. Optionally, to enable HTTPS encryption for your site, select Enforce HTTPS. It can take up to 24 hours before this option is available. For more information, see "Securing your Páginas de GitHub site with HTTPS."

    Enforce HTTPS for custom domains option

Leer más

Pregunta a una persona

¿No puedes encontrar lo que estás buscando?

Contáctanos