Multiple Domains

It is possible to set domain for a page to indicate that it belongs to a specific domain.

When generating a page with a domain setting the domain will be appended to the destination directory. It is recommended that if domain is set for one page, it should be set for all pages, so that the top level of the destination directory only contain domain directories.

This can be done using the defaults hash in the configuration file, for example to make pages default to macromates.com and pages under sigpipe/ use sigpipe.macromates.com, we would set:

defaults:
  - values:
      domain: macromates.com
  - values:
      domain: sigpipe.macromates.com
      base_dir: sigpipe
    scope:
      path: sigpipe

We also set base_dir which makes file paths relative to base_dir instead of the source directory. This means we can have all our files in sigpipe/ but this path will not be recreated in the destination directory.

The base_dir only affects files without an explicit permalink setting, or files which use :path in their permalink.

An advantage of managing multiple domains under the same project is the ability to share resources and ensure proper cross-linking. For example our layout may contain this:

<link rel="stylesheet" href="{% link css/main.scss %}">

Even if we use this layout for multiple subdomains, they will all link to the correct domain.

By default the scheme used when generating absolute URLs for pages that has a domain setting is taken from site.url but it can be changed using the scheme front matter setting. In theory one could change the scheme for an RSS feed to feed so that links to that page (created via the link tag) would automatically use feed as URL scheme.