# Changing Your Website URL

## Changing your Website URL

When you create your GitHub Pages website for the first time, its URL is decided by your GitHub username, and the name of the repo you've created. For example, if your username is `JacobWG`, and you named your repo `bestcomic`, then the URL for your website will be <http://JacobWG.github.io/bestcomic/>.

There are two ways to change the URL for your web page:&#x20;

* Change your username or repo name
* Assign a custom domain to your website

### Changing your Username

Changing your username will change the part of the URL right before `.github.io`. It will also change the username you use to log into GitHub, and you will have to relogin to GitHub Desktop.&#x20;

To change it:

1. Click your icon in the top right corner of any GitHub page, then click **Settings**.&#x20;

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FBJTiLHAgdhB9n1syyS9b%2Fchange_username01_account.png?alt=media&#x26;token=a603402f-355f-4f8b-bd49-2cfeb1685d8d" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FDnul5A1dbUPj1cJTWaDt%2Fchange_username02_settings.png?alt=media&#x26;token=38968665-f0c8-43c0-a319-4b216a551ecd" alt=""><figcaption></figcaption></figure>
2. In the list of options on the left, click **Account**.&#x20;
3. Click **Change Username**. Follow the steps GitHub gives you to complete the process.&#x20;

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FQsxzGgKdXWBVq7ESdUiU%2Fchange_username03_change.png?alt=media&#x26;token=ed43e674-e891-4a82-be60-dd714981d0d6" alt=""><figcaption></figcaption></figure>

### Changing your Repo Name

Changing the name of your webcomic's repository will change the last part of your URL.&#x20;

To change it:

1. From the main page of your repository, click **Settings**.&#x20;

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2Fb6ZR6G7ILlgIYj6RFL1y%2Fchange_repo01_settings.png?alt=media&#x26;token=77143656-a392-4dc3-8844-06170fe4855d" alt=""><figcaption></figcaption></figure>
2. The first option in General Settings shows your repo name. Click in the text box, make your desired changes, then click **Rename**.&#x20;

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FjXeSqL5HttSDVhy7D0Ti%2Fchange_repo02_rename.png?alt=media&#x26;token=a1bcdc4b-0dea-4181-8473-503fe70ae020" alt=""><figcaption></figcaption></figure>

## Moving to a Custom Domain

At some point, you will likely want to host your comic from a custom domain, so your readers don't have to keep going to your github.io URL. Fortunately, GitHub Pages supports this!

### Create an A and CNAME Record for your Domain

The first thing you'll need to do is set an A and CNAME record in the DNS settings of your domain registrar's management page. The exact instructions depend on which registrar you've registered your domain with and is beyond the scope of this article. Most registrars will have their own help documentation telling you how to do this.

You will want to set the following values on your records. This is offered as a convenient reference, and is **not** definitive; the field names below may not match what you see on your registrar's website:

#### A

This record points your apex domain (e.g. `bestcomic.com`) directly at the GitHub Pages servers. This record is technically optional, but recommended.

* **DNS name:** empty string (it may look like `bestcomic.com.` in your settings)
* **Values:**
  * `185.199.108.153`
  * `185.199.109.153`
  * `185.199.110.153`
  * `185.199.111.153`

#### CNAME

This record points the `www` subdomain (e.g., `www.bestcomic.com`) to your GitHub Pages site. This record is required.

* **DNS name:** www (it may look like `www.bestcomic.com.` in your settings)
* **Canonical name:** \<username>.github.io. (e.g. `ryanvilbrandt.github.io.`)

You can leave fields like "TTL" as their default values.

GitHub provides more detail on DNS records and what values to enter for them. See [Managing a custom domain for your GitHub Pages site](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#dns-records-for-your-custom-domain).&#x20;

### Change your GitHub Pages Settings

1. From the main page of your repository, click **Settings**.&#x20;

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2Fb6ZR6G7ILlgIYj6RFL1y%2Fchange_repo01_settings.png?alt=media&#x26;token=77143656-a392-4dc3-8844-06170fe4855d" alt=""><figcaption></figcaption></figure>
2. In the list of options on the left, click **Pages**. Find the **Custom domain** entry in the Pages settings.&#x20;

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FfXUX1VhGZkd9vRxewXpd%2Fcustom_domain02_pages.png?alt=media&#x26;token=18b208b1-fa5e-48c7-95fa-b70226c01638" alt=""><figcaption></figcaption></figure>
3. Fill out the text field for the Custom Domain to match whatever custom domain you want to assign to your website, then click **Save**.&#x20;

   <figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FaYhifR5iDXKXTEf7XS7u%2Fcustom_domain03_set_domain.png?alt=media&#x26;token=7f799b8f-da52-4820-8695-67000b97e00f" alt=""><figcaption></figcaption></figure>

The page will reload with a blue banner that says `Custom domain "<domain name>" saved.`

### Create a CNAME file in your Repository

In your repository, create a new file called `CNAME` with no extension. In the file, add only a single line with your new domain, e.g. `www.bestcomic.com`&#x20;

<details>

<summary>How do I make a file with no file extension?</summary>

Windows by default makes it difficult to create files with no file extension. This section will walk you through a simple method to do so, but any method will work.

First, open File Explorer and go to the View tab, and check the box "File name extensions".

<figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FRghTOo4X70v4YmMYISnn%2Fimage.png?alt=media&#x26;token=606b8b7c-e045-4cdc-b0e6-74230c11eab9" alt=""><figcaption></figcaption></figure>

Then, go to your repository. Right-click anywhere in the background of the folder, and go to New > Text Document.

<figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FBkrW8ZTqCNPEl0DrZQEq%2Fimage.png?alt=media&#x26;token=e46541d2-acb2-4573-be8f-3641173cbe39" alt=""><figcaption></figcaption></figure>

This will create a new text document in your folder and highlight the name to let you change it.

Select the whole filename, including the `.txt` extension, and replace it with `CNAME` and hit enter. A dialog will pop up warning you that the file "might become unusable". This is normal, and you can finish renaming the file by clicking **Yes**.

<figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FDVaJJBM6qZSV9kwjFlOs%2Fimage.png?alt=media&#x26;token=0930380f-1fc7-476b-b25b-1c4c49689d3c" alt=""><figcaption></figcaption></figure>

The CNAME file has now been created, and it should look like below.

<figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2F9v06RNWXpZLKaJiPYPsJ%2Fimage.png?alt=media&#x26;token=0cacaca0-c80a-43df-92c2-67b07585a0c6" alt=""><figcaption></figcaption></figure>

Now, open the file so you can add your domain by right-clicking the file and clicking **Open with.**

<figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2Fx9q0l5HNdNnga9wDMwL2%2Fimage.png?alt=media&#x26;token=f84e4184-b970-49b6-a2cc-459440809cbc" alt=""><figcaption></figcaption></figure>

In the new dialog that pops up, select **Notepad** and click **OK**.

<figure><img src="https://2237275703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmiTVVg3fJxJoQNT4AA65%2Fuploads%2FCpcmYm4JGA9E3ScMrQsH%2Fimage.png?alt=media&#x26;token=6680b833-5460-44f2-a6b9-306d5de3aa76" alt=""><figcaption></figcaption></figure>

This will open the file in Notepad. Add only a single line with your new domain, e.g. `www.bestcomic.com`&#x20;

Save and close Notepad, then commit and push your new CNAME file up to your repo. Your website will rebuild and deploy, and should now be accessible from your custom domain!

</details>
