Tutorial

How to add a subdomain

Point blog.example.com or shop.example.com somewhere useful, and know which record type to use.

Ben Johnson · last checked 2026-09-21 · 4 min read

TL;DR
  • A subdomain is a DNS record, not a new domain. You can create unlimited subdomains under one domain at no extra cost.
  • You need exactly two things: a DNS record pointing to your server, and a folder on the server with the same name as the subdomain.
  • Use specific records like staging.example.com, never a wildcard, unless you want every typo to reach your site.
  • Subdomains share your existing hosting account’s disk space, file limits and process pool — they do not count toward the three-account maximum.

A subdomain is just another DNS record. You do not need to buy a new domain. If you own example.com, you can make staging.example.com, shop.example.com or test.example.com without paying anything extra.

The full job takes three steps: one record in DNS, one folder on disk, one check that it works. You can skip steps, but the site will not load.

Pick a name and create the record

Decide what you want before the dot. staging, dev, admin, files — one word, no spaces, letters and hyphens only.

Go to the DNS control panel for your domain. Your registrar or hosting provider will have an area labelled “DNS records”, “Zone editor” or “Advanced DNS”. Add a new record.

  • Type: CNAME if the subdomain points to another domain (like a GitHub Pages URL). A if it points to an IP address. The a-record-vs-cname guide explains the difference in detail.
  • Name: the subdomain itself. For staging.example.com, put staging.
  • Value: the destination. An IP address for an A record, the target domain for a CNAME.
  • TTL: 300 (5 minutes) during setup, then leave it at the default.

Do not use a wildcard record (*.example.com) unless you genuinely want every possible subdomain that anybody types. Wildcards catch typos and can turn traffic meant for someone else into your problem. Set specific records.

Create the folder on the host

A DNS record tells browsers where to find your server. It does not tell the server what files to serve. You need a folder that matches the subdomain.

Inside your web root (the folder where your main site lives, often public_html), create a directory with the subdomain name. For staging.example.com, make a folder called staging inside public_html. On a typical shared host the path looks like:

/home/username/public_html/staging

If you are using cPanel, there is a “Subdomains” tool that creates both the DNS record and the folder together. Other control panels have similar tools. Creating one but not the other is the most common mistake. If the folder is missing or the name does not match, visitors get a 404 not found page.

Confirm it works

Wait a few minutes for the DNS change to propagate. Then test two things.

First, check the DNS record itself. Use a DNS lookup tool and enter your subdomain — staging.example.com. You should see the record type and value you set. If nothing appears, the record was not saved or the TTL has not passed.

Second, visit the subdomain in a browser. You should see the content of the folder you created. If the folder is empty, you get a blank page or a directory listing. If you get a 404, the folder path is wrong. If you get a 508 error, you hit a resource limit — check the 508 error page for what to do.

What to put in the folder

A subdomain folder is just a web root. It can contain anything a normal website folder can: HTML files, PHP scripts, static assets.

For a simple start-up page, drop in an index.html file. For a full website, upload the same structure your main site uses. The static website guide covers the basics of getting files served.

Subdomains are useful for:

  • Testing a redesign without touching your live site
  • Hosting a separate application on the same account
  • Creating a file-sharing page at files.example.com
  • Running a blog on blog.example.com

Each subdomain counts against your account’s file and resource limits the same as any other folder. The combined total of all your sites on one account must stay under the published caps.

Add a subdomain in your control panel

The exact button labels differ between hosting providers, but the pattern is the same everywhere. Look for “Subdomains”, “Add subdomain” or “Create subdomain” in your hosting dashboard.

In most control panels, you type the subdomain name (just the part before the dot) and select the main domain from a dropdown. The panel then creates the DNS record and a folder for you. Some panels also let you choose a custom document root path instead of using the subdomain name as the folder.

On a provider where you manage DNS separately from hosting, you must create the record and the folder by hand. Write down the subdomain name and the folder path so they match exactly. A single character difference — a missing hyphen, the wrong word — and the site will not load. (Capital letters do not matter in a hostname; everything else does.)

After the record and folder exist, upload your files into the subdomain folder. Visit subdomain.yourdomain.com to confirm everything works. The process takes about ten minutes on a good day and half an hour if DNS is slow to update.