What is a subdomain, and when should you use one?

Domain 4 min read

A subdomain is a prefix written before the domain name, separated by a full stop: in the address blog.pelda.hu, blog is the subdomain and pelda.hu is the main domain. www is also a subdomain, but it is so commonplace that we do not think of it that way.

You do not need to register subdomains separately, and there is no additional charge: if you own the domain name, you can create as many subdomains under it as your hosting plan or DNS provider allows. Technically, it is a DNS record that specifies which server the name points to.

A subdomain is not the same as a domain level. In the address pelda.co.hu, pelda is a third-level name, but this is your registered domain because .co.hu itself functions as an extension; a subdomain of this would be, for example, blog.pelda.co.hu.

What is it for?

  • A separate section with its own application: an online shop (bolt.pelda.hu), a customer portal or a knowledge base can run on a different system, or even on a different server, to the main website.
  • Test environment: you can test changes at staging.pelda.hu before going live (setting up a staging WordPress site).
  • Services: mail.pelda.hu or ftp.pelda.hu are the addresses for email and file uploads.
  • An external service under its own name – such as hirlevel.pelda.hu or tudastar.pelda.hu – can point to an external system via a CNAME record.
  • Language or regional variants: for example, en.pelda.hu, although a subdirectory would also work for this.

Subdomain, subdirectory or separate domain?

  Subdomain Subdirectory Separate domain
Example blog.pelda.hu pelda.hu/blog pelda-blog.hu
Special charge None None Yes, annually
Can I move to another server? Yes, via DNS Only with more complex configuration Yes
In-house system Easily On the same hosting account, in a separate folder Easily
Cookies and login Can be managed separately Shared with the main page Completely separate

From a search engine optimisation perspective, there is no clear winner: Google can handle both solutions, and the impact is determined by the content and internal linking. In practice, it is simpler to maintain a subdirectory as part of the main website, as there is no need to set up analytics and Search Console separately, for example. Therefore, unless there is a technical reason for using a subdomain – such as a different system or server – a subdirectory is the more obvious choice for blogs and service pages.

A separate domain is recommended if you have a separate brand or an independent project. This can be hosted on your hosting account as an additional domain. The differences between the two solutions are detailed in our blog post ‘Additional domain vs. subdomain’.

How do I create a subdomain?

On cPanel hosting, go to the Domains page, click the ‘Create A New Domain’ button and enter the full subdomain name. The steps are described in the article on adding domains and subdomains.

On the ‘Domains’** page of the **web hosting section:

  1. Click on the ‘Add Domain’ button.
  2. In the ‘Domain type’ section, select the ‘Subdomain’ option.
  3. Enter the subdomain in the ‘Full domain name’ field, for example blog.pelda.hu.
  4. In the ‘Domain purpose / Hosting type’ section, ‘Local directory’ points to a folder on your hosting account, whilst ‘Forward documents’ redirects to another website.
  5. Click the Save button.

If you manage your domain’s DNS elsewhere, you will also need to add an A record or a CNAME record for the subdomain there. If the domain uses our name servers, the control panel will take care of this. The new record usually takes effect quickly, but it may not be visible everywhere whilst the DNS is propagating.

What should you look out for?

  • SSL: the certificate is required for every subdomain. The free certificate provided with cPanel hosting and web hosting can resolve this, but the subdomain’s DNS must already point to the hosting account. A wildcard certificate covers subdomains at one level: *.pelda.hu is valid for the address blog.pelda.hu, but not for teszt.blog.pelda.hu.
  • Subdomains are public. Issued certificates are recorded in public logs, which is why even a domain such as teszt.pelda.hu, which is intended to be private, can be found. This is explained in the Certificate Transparency article. Please protect your test environment with a password.
  • Do not leave any orphaned records. If you cancel an external service, be sure to delete the CNAME record pointing to it as well. An attacker could take over a record left behind if they register the target address with the service provider and display content under your name.
  • Email: emails sent on behalf of the subdomain may require separate SPF and DKIM records. This is covered in the article on SPF records.
  • Search engines: the test environment should not appear in search results. Indexing is disabled by default for WP Toolkit clones.

The article on TLDs explains the structure of domain names.

Back: Domain articles (31)