Subdomains vs. Subdirectories

When you’re first getting started with a new space on a new web host, you might think of yourself as owning a small “territory” of the web. Everything you place in your public folder on the server becomes available for anyone on the web to see (assuming they know the address of your site and the files you’ve placed there).

If you’re just putting up a handful of static HTML pages which you want to make available to colleagues, friends, or family by sending them links, then working with this large, unorganized space may work. But as soon as you get to the point where you want to organize your site, you’re going to need a new strategy.

Consider this scenario: you want to have a blog on your new web space, where you are engaging in public scholarship. In addition, you are working on a large research project that requires you to build a web-based repository of digital images related to your discipline. You intend to use one application (say, WordPress) to manage the blog. For your research project, you’ve settled on another open-source application (Say, Omeka). Both of these are applications that need to be installed on your web host, but you can’t just put them both at your main domain name – if you did, both sites would quickly experience conflicts and errors. You need to cordon off separate spaces for your different Web “properties.”

There are two primary strategies for parceling up your web space. You can create subdomains or subdirectories. But before you can understand the difference, you need to first understand what we mean when we talk about your root domain.

Root Domain

Let’s say you’ve registered a new domain for digitalscholarship.brown.edu called myresearch.digitalscholarship.brown.edu. Anything that is stored at this core URL is considered to be at the root of your domain. You may decide that you simply want to have a single site on your Web host (say a blog running WordPress), and you can then install WordPress at your domain’s root. To get to your site in this scenario, users would simply go to myresearch.digitalscholarship.brown.edu.

Subdomains

If you want to have more than just a single website at the root of your domain, you will have to decide now to organize your space. One way to do so is by setting up subdomains.

You may already be familiar with the concept of subdomains, even if you don’t know it. Consider Google’s website at https://google.com. As you browse features of that site, you’ll notice that the domain changes. When you’re looking at your Gmail account, for example, the domain changes to https://mail.google.com. Now the root of the url is mail.google.com, indicating that you’re on the part of the site that is dedicated to Google’s mail services.

In this instance, mail.google.com is a subdomain that provides a different utility than google.com. The domains serve two purposes: they help to organize the site from a technical perspective, but they also serve as indications to the users that they are in a new/different space.

As you work on your site, you’re welcome to create as many subdomains as you like, and in each subdomain you can actually create a distinct, individual Web site.

Subdirectories

The alternative to subdomains for organizing your space is to use subdirectories. These function much like file folders on your computer. Instead of installing a WordPress site at myresearch.digitalscholarship.brown.edu you would place it in a subdirectory called “research” making the address digitalscholarship.brown.edu/research. Setting up a subdirectory is easy. You can create folders on the fly when installing applications (like WordPress), and you can also manually create them in your file browser.

There is one particular issue you need to be aware of: Let’s say you have installed WordPress as your primary blog at myresearch.digitalscholarship.brown.edu. Later, you decide you want to install WordPress again for an image gallery site, and you want to place it at myreearch.digitalscholarship.brown.edu/gallery. If for any reason you already have a page on your WordPress site called “Gallery,” then the url myresearch.digitalscholarship.brown.edu.com/gallery is already be taken.  If you try to create a subdirectory of the same name, you’ll get a conflict and errors.

Tips & Review

  • Subdomains are generally a cleaner, more elegant solution to organizing your site. You’re less likely to get conflicts or errors. However, when using subdomains the process is slightly more complicated: You must create subdomains first before you can install anything in them. Subdomains also have much longer URLs, as you will prepend the subdomain name to [yourname].digitalscholarship.brown.edu.
  • Subdirectories don’t come with the neat URLs that subdomains have, but they are easier to set up, and may be easier to remember, as the application is a folder within the domain. They have the potential to for conflicts with existing web pages.
  • As soon as you create subdomains or subdirectories to organize your site, youhave to consider how people are going to find them. If you have created a new primary blog at blog.myresearch.digitalscholarship.brown.edu, and someone goes to myresearch.digitalscholarship.brown.edu, they won’t see the new site. One solution is to set up redirects so as to avoid this issue. You can also create links from pages on one subdomain of your site to another.
  • If you just need one site, installing at the root of your domain is the easiest thing to do, at least as you’re getting started. You can always add more pieces to your territory later with either subdomains or subdirectories.

Tutorials