How to use subdomains for your website
The way you organize content and services is an important aspect of planning and developing your website. Your website’s structure can have an impact on how usable your website is, how easy it is for internet users looking for specific information to find it, and how you target different audiences or different types of users. It can also have a strong impact on your website’s search engine ranking.
That makes structuring your site well an important task when building and growing your website, as well as something you should continue to evaluate and develop as your traffic grows, as your conditions change, and as you add or remove content or services.
One tool you can use to structure your site is subdomains.
Subdomains are a critical tool in structuring your website, and so understanding and using them intelligently and deliberately can help reap the rewards of a well-structured website.
What is a subdomain?
Before we can accurately describe what a subdomain is, you’ll first need to know what a domain name is. In addition to being one of the main ways people find you on the internet, a domain name is essentially an internet address that belongs to you alone that takes the form of a word or phrase, plus one of hundreds of existing domain endings, most commonly .com.
Read our technical description of what a domain name is here
When you buy a domain name, you could say that what you’re really buying, technically speaking, is control over the domain’s DNS zone, which is to say, registering a domain name gives you the right to associate that domain name with any services, including web hosting services where you build and host your website.
When you use your DNS zone to tack on more text, separated from your domain by a dot, you’re adding a subdomain. So, for example, if you registered example.com, you can associate example.com to your website. But you can also associate foo.example.com to your website, or even example.foo.example.com.
The most commonly used and created subdomain is the www subdomain. Almost every website on the internet uses this subdomain, primarily because in the early days of the worldwide web, this subdomain was used to distinguish between web services and other services (like ftp or email) that might be hosted on a domain name.
Why would you use a subdomain or subdomains?
This hints at one historically common usage for subdomains — to distinguish between different services hosted on a domain name. Mail servers and ftp servers are still often hosted on subdomains.
But since the web has become the dominant internet service, websites have incorporated subdomains within their structures for other uses.
Here are a few common ways that websites use subdomains:
- Create a testing environment: this often takes the form of a subdomain like beta.example.com, where a beta version of an upcoming site or new features to be added can be tested without impacting the operation of the main site
- Differentiate between different types of web services or content: for example, you might want to host your blog and your e-commerce site separately from each other, on blog.example.com and shop.example.com.
- Host a mobile version of your website: you sometimes see this as m.example.com, where rather than using a responsive design, a different version of the website is served depending on the type of device used to access it
- Create localized versions of your website in different languages: for example, you might use fr.example.com for your French-language website, en.example.com for your English-language website, and es.example.com for the Spanish-language version of your website
- Allow subsidiaries control over their own sites: if you have a business with locations in several cities, you might create separate websites for each and use subdomains like nyc.example.com, paris.example.com, and london.example.com
- Create a network of websites that aren’t necessarily related to one another: for example, you can purchase a blog site like example.wordpress.com from WordPress.com
- Target specific groups of users: like if you wanted to create a logged in space like user.example.com and a guest space like guest.example.com
These are just a few common examples, but you can use a subdomain for virtually any structure you want to introduce to your website. You could theoretically host every page on your website on a different subdomain, like contact.example.com for your contact page, about.example.com for your about page, etc.
Are subdomains or subdirectories better for SEO?
The alternative to using a subdomain for a new section of your website is to use a subdirectory. This is when, rather than adding to the “front” end of your website’s address like with a subdomain, you add to the “back” end of your website’s address, that is, to the right of your domain name (and after a slash).
So, for example, you might use example.com/foo instead of foo.example.com.
It’s a commonly held belief that subdirectories (example.com/foo) are better for search engine optimization, but Google’s search gurus have debunked this.
That doesn’t mean that there isn’t some truth to this.
Mainly, if your subdomain or subdomains are a main part of your site, you should be sure to link to them from other pages on your site. Otherwise, search engines may not know to index your subdomains with your domain name.
How do you create a subdomain?
In order to create a subdomain, you’ll first need to make sure that you have a domain name. If you don’t have a domain name search for one here:
Once you have a domain name or if you already have one, adding a subdomain is as easy as editing your DNS zone file.
But first, you’ll need to know what your subdomain is pointing to. If you’re creating a subdomain for a new blog using WordPress, for example, you’ll need a hosting instance that you can host your new WordPress site on.
You can launch your site creation here by choosing your service level if you want to use Gandi’s Simple Hosting to install a new WordPress site on a new subdomain. You’ll be asked to choose a domain to install your WordPress site on. Then you can choose the address of your site. By default, ‘www’ will appear in this field, but you can replace that with any subdomain name you want.
Then once you check out, our system will install WordPress for you, including adding the subdomain to your DNS zone file.
If you want to use your new subdomain to create an online store using the Prestashop e-commerce platform, start here and follow the same process.
Otherwise, if you already Gandi Simple Hosting and want to add a new subdomain for WordPress, Prestashop, or another type of site you want to install on your Simple Hosting instance, start by going to your Simple Hosting dashboard and add your subdomain as a new site.
Read more about how to add a new site to your Simple Hosting instance
Otherwise, if you’re hosting elsewhere besides Gandi, you’ll need to make sure to set up your hosting to work with the new subdomain you’re going to create. You’ll need to check with your hosting provider for the exact process, but on the Gandi side, you’ll need to update your DNS zone file.
From your Gandi dashboard, click “Domain” on the left. Then click the domain name you want to add a subdomain to from the list of domain names. Click the “DNS Records” tab and then click the “Add” button to add a new record.
Depending on your hosting provider, you’ll probably need to add either a CNAME type record or an A type record. A CNAME record is more common and points your new subdomain to another domain name owned by your hosting provider. An A record points to an IP address.
The ‘name’ is where you enter the name of your new subdomain (that is, the part that will come before the . that becomes before your domain name).
What happens when you stop using a subdomain?
You might decide to restructure your site later to use subdirectories instead of subdomains or you might eliminate a type of content or a service or just migrate from shop.example.com to store.example.com, for example.
In any of these cases, it’s important to remember to keep your DNS zone file clean to avoid the possibility of a subdomain hijacking. This happens when a subdomain points to a service you used to use for hosting but you no longer have hosting connected to it and someone else signs up for hosting using your subdomain, and because you already have the DNS pointing to the correct place, they can host a website on your domain name.
To keep your DNS zone clean, just make sure you delete the DNS record for your subdomain if you’re not using that subdomain anymore.
Whether your want to create localized versions of your website, have separate services you want to host on an easy-to-remember address, or you want to create a beta version of your website to test new features, you can do it by adding a subdomain.
Tagged in DNSprestashopSimple HostingWordpress