SEO¶
Install the modules that give every site its own sitemap, robots.txt, redirects, canonical link, URL aliases and llms.txt.
Each module works on its own; install the ones you need:
| Feature | composer require |
drush en |
|---|---|---|
| Sitemap | drupal/sites_simple_sitemap |
sites_simple_sitemap |
| robots.txt | drupal/sites_robotstxt |
sites_robotstxt |
| Redirects | drupal/sites_redirect |
sites_redirect |
| Canonical link and hreflang | drupal/metatag |
sites_metatag |
| URL aliases | (ships with Sites) | sites_path_alias |
| Pathauto | drupal/pathauto |
pathauto |
| llms.txt | drupal/llms_txt_sites |
llms_txt_sites |
The hub serves no sitemap, robots.txt or llms.txt. What a site's people set for their site: Site settings and the URL pages.
Sitemap¶
Needs Sites Simple XML Sitemap
Part of Sites Simple XML Sitemap.
Each site serves its own /sitemap.xml from
Simple XML Sitemap: its
content, with hreflang alternates where other sites serve it in another
language or region. A sub-site's content is in its main site's sitemap.
- Open
/admin/config/search/simplesitemap/entities, choose Global, and tick Enabled for the entity types the sitemaps may list. Menu links are not offered per site. - On each site type, set defaults in the Sitemap rows: per bundle Index, Priority, Change frequency and Include images.
- A site changes them in its Sitemap section
(
/admin/sites/{site}/sitemap), with Manage site settings or Administer sitemap settings.
Simple XML Sitemap generates the sitemaps on cron.
- The sitemaps use the Sites sitemap type
(
/admin/config/search/simplesitemap/types/sites). Of the URL generators, only Entity URL generator works per site. - A site defined in code gets a sitemap only when it holds content.
- A sitemap you add by hand at
/admin/config/search/simplesitemapis served on the hub by its name, at/sitemaps/{name}/sitemap.xml.
robots.txt¶
Needs Sites RobotsTxt
Part of Sites RobotsTxt.
Each site serves its own /robots.txt from
RobotsTxt, or the global one
while its own is empty. A sub-site has none: the hostname's /robots.txt is
its main site's.
- Delete
robots.txtfrom the web root and keep Composer from restoring it:"[web-root]/robots.txt": falseunderextra.drupal-scaffold.file-mapping. Otherwise the web server serves that file on every host. - Write the global file at
/admin/config/search/robotstxt, under Global. - A site writes its own in robots.txt for this site, in its robots.txt
section (
/admin/sites/{site}/robots-txt), with Manage site settings or Administer robots.txt.
To refuse every crawler on staging only, tick Environment overrides for robots.txt content on the site type and set the staging text on the section's Environments tab.
Redirects¶
Needs Sites Redirect
Part of Sites Redirect.
Every redirect belongs to one site and answers there only; one source path can redirect differently per site. A redirect for a platform-wide path belongs to the hub. A redirect created for a changed alias belongs to the alias's site. It needs Sites path alias.
- Redirects that existed before have no site and match nowhere.
Sites status (
/admin/sites/reports/status) counts them; its Review them link lists them. Give each a site. - To let a site's people manage its redirects, grant Administer individual
URL redirections in a per-site role. They work in
the site's Redirects section (
/admin/sites/{site}/redirect).
Canonical link and hreflang¶
Needs Sites Metatag
Part of Sites Metatag.
Without it, every site's canonical link points at itself, and Drupal's status report warns. With it, Metatag's Canonical URL tag follows the sites that show the content, and Hreflang alternates (Sites) names the page in the other languages and sites.
- Enable it with Drush, not a configuration import: only then does the install switch the hreflang and shortlink tags on in Metatag's global defaults. Export the configuration afterwards.
- Leave
metatag_hreflangoff. - On each site's Identity page (
/admin/sites/{site}/identity), Canonical link sets where the link points: This site, The content's canonical site (the default) or None (Sites adds no canonical link). Region, a two-letter country code, makes sites regional variants of each other.
sites_metatag.settings has no form. Its defaults follow Google's guidance on
canonical and localized pages; change a key with Drush or in settings.php:
| Key | Default | Decides |
|---|---|---|
canonical.across_regions |
false |
Whether The content's canonical site may name a site of another Region. Off, a regional site names its main site of the same region, or itself. |
canonical.own_variants |
true |
Whether a site that shows its own version of the content (an override) names itself. |
hreflang.canonical_pages_only |
true |
Whether only a page whose canonical link names itself carries alternates. |
hreflang.minimum |
2 |
The fewest alternates a page carries; below it, none. |
hreflang.x_default |
true |
Whether an x-default alternate names the page on the content's canonical site. |
Per page: Canonical link and hreflang.
URL aliases¶
Needs Sites path alias
Part of Sites path alias.
Every alias belongs to one site; one path can name different content on different sites. An alias without a site matches nowhere for site content, and everywhere for other paths, like a view.
- Aliases that existed before have no site. Sites status counts them; Review them lists them. Give each a site, or let Pathauto generate them anew.
- To let a site's people manage its aliases, grant Administer URL aliases
in a per-site role. They work in the site's URL aliases section
(
/admin/sites/{site}/path).
Pathauto¶
Needs Sites Pathauto
Part of Sites Pathauto.
Sites Pathauto installs itself once Pathauto and Sites path alias are both on. Pathauto then generates one alias per site of a content item, from that site's version, and regenerates them when the item's sites change.
- Set up the patterns at
/admin/config/search/path/patterns. They apply to every site; tokens like[current-site:label]resolve per site. - For existing content, run Bulk generate
(
/admin/config/search/path/update_bulk).
llms.txt¶
Needs Sites llms.txt
Part of Sites llms.txt.
Each site serves its own /llms.txt: the header text, then the llms.txt
sections that belong to the site. A section on no site is served nowhere. It
needs Sites content.
- Write the header on llms.txt configuration (
/admin/content/llms-txt). - Keep llms.txt section assignable on the site types (it is by default); see Content on sites.
- Create the sections and assign each to its sites.