parallelogram / craft-seo
SEO for Craft CMS: meta tags, Open Graph, JSON-LD, sitemaps and site-root files from fallback profiles that deploy with your code.
Package info
github.com/parallelogram-dev/parallelogram-craft-seo
Type:craft-plugin
pkg:composer/parallelogram/craft-seo
Requires
- php: ^8.3
- craftcms/cms: ^5.6
- parallelogram/craft-kit: ^0.2 || *@dev
Requires (Dev)
- carthage-software/mago: ^1.59
- phpunit/phpunit: ^12.0
Suggests
- parallelogram/craft-images: Social images from a 1200×630 “social” size set, with AVIF/JPEG variants.
Provides
None
Conflicts
None
Replaces
None
README
SEO for Craft CMS: page titles, descriptions, canonical URLs, robots, Open Graph, Twitter cards, hreflang links and JSON-LD, resolved from fallback profiles that live in project config and deploy with your code.
Status: 0.1.0 in development: profiles, site values, the resolver,
{{ seo() }}, the SEO field and JSON-LD are in. Sitemaps, site-root files and tracking follow. Seecraft-optimiser/DECISIONS.mdin the Parallelogram workspace. Not yet listed on the Craft Plugin Store.
Requirements
- PHP 8.3 or later
- Craft CMS 5.6 or later
- Optional: Parallelogram Images for sharing images from its size sets
How a page's meta is worked out
Each value goes through the same cascade. Later steps win:
- Site values, stored in the database per site and editable on production: the site name, a default description and image, and title and description patterns.
- The profile for the element, from project config: ordered fallback chains for the title, description and image. A section's profile wins over its entry type's. Categories use their group's profile; Commerce products their product type's.
- The editor's overrides in the SEO field, when the element's layout has one.
- The template, with
seo.set(...).
The title and description found by steps 1–3 then go through the site's patterns. Values set by the template are used exactly as given.
A description found by a fallback chain (or the site default) is shortened to the description limit in the plugin's settings (155 characters by default): markup stripped, whitespace collapsed, and cut at the last whole word with an ellipsis, after its pattern. The sharing description and the JSON-LD description use the same shortened text. A description an editor typed in the SEO field, or a template set with seo.set(), is used as given.
Without a profile, an element's title is its own title, and its description and image are the site defaults.
Fallback chains
A chain lists the places to look, tried in turn until one has a value:
seoTitle → title
summary → default
hero → gallery[0] → default
hero → asset:3c836715-a4a0-4fa5-8cae-1e986ace8694 → default
Each step is a field or attribute handle (section.name reaches into related values), optionally with an index for relation fields (gallery[1] is the second related asset). default is the site's default. In an image chain, asset:{uid} is one chosen image, such as a fixed share image for every page of a section; the editor's Choose an image… button adds it. A chosen image that has been deleted is skipped. Markup is stripped from text and whitespace collapsed. A related element gives its title; one without a title, such as a Matrix block, gives the text of its fields. A Matrix field step without an index (body) joins the text of every block, and body[0] reads only the first.
Patterns
Patterns use Craft's object-template syntax, the same as entry title formats. {title} is the title the chain found, {description} the description, {siteName} the site name, and anything else is read from the element:
{title} – {section.name} | {siteName}
A pattern that can't be rendered is logged, and the unpatterned text is used. A title that fell back to the site name (a page without an element, or an element whose chain found nothing) is used as it is, so a pattern ending in {siteName} doesn't repeat it.
Templates
Nothing is added to your pages automatically. Call seo() in the document head:
<head> {{ seo() }} </head>
It resolves the element the URL matched. Pass another to describe a different one: {{ seo(product) }}.
Set values before calling it:
{% do seo.set('title', 'Search results') %}
{% do seo.set({
description: 'Projects in Melbourne.',
image: entry.hero.one(),
ogType: 'article',
}) %}
Keys: title, description, image (an asset or an absolute URL), canonical, robots, ogType, ogTitle and ogDescription. Setting a key to null or an empty string clears it. An unknown key is an error.
seo.meta() returns the resolved values for templates of your own, e.g. seo.meta().openGraph.share.title. Add to the page's JSON-LD with seo.schema({...}) (see JSON-LD).
What it outputs
<title>and the meta descriptionrobots:noindex, nofolloweverywhere but the live environment (Settings → Live environment,productionby default), whatever a template or editor sets. Error pages (a 4xx or 5xx response, such as the 404 template) arenoindexand have no canonical URL- The canonical URL: the element's URL with every query parameter removed except the allowed ones (
pageby default). Later pages of a paginated listing are canonical to themselves. - hreflang links to the element's versions in other sites, plus
x-defaultto the primary site's version, when it is live in more than one site - Open Graph (
og:type,og:site_name,og:title,og:description,og:url,og:locale,og:imagewith its size and alt text) and Twitter card tags (summary_large_imagewith an image,summarywithout). The sharing title is the page's title without the site's pattern, sinceog:site_namealready names the site. In order of precedence:seo.set('ogTitle', …), the SEO field's sharing title,seo.set('title', …), then the page's title before the pattern - One
<script type="application/ld+json">with the page's JSON-LD graph - In the live environment only: Google Consent Mode defaults and, for sites that don't use ParallelogramJS, each tracker's own snippet (see Tracking)
Every value is HTML-escaped. In the JSON-LD, <, > and & are written as \u003C, \u003E and \u0026, so no value can end the script.
JSON-LD
{{ seo() }} ends with one JSON-LD @graph, whose nodes refer to each other by @id:
| Node | @id |
From |
|---|---|---|
| Organization | {site}/#organization |
Site values → Organisation: its schema.org type (Organization by default, e.g. LocalBusiness), name (a pattern, {siteName} by default), logo (at its own size) and the web addresses of its Social profiles (sameAs). A local business type (any of the "Local businesses" in the type picker) also gets its address, phone, email and opening hours (openingHoursSpecification), when given. Left out when nothing names it. |
| WebSite | {site}/#website |
The site name and language, the Organization as publisher, and a SearchAction when the site search URL contains {search_term_string}. |
| WebPage | {page}#webpage |
The page's title, description, canonical URL, language and sharing image, isPartOf the WebSite. |
| BreadcrumbList | {page}#breadcrumb |
The home page, the profile's index page (when set), the element's ancestors in a structure (those with URLs), then the element. A step whose URL is already in the trail is left out, as is an index page that is the element itself. Left out when the trail is a single step, e.g. on the home page. |
| Main entity | {page}#primary |
The profile's schema type and property mapping (below). |
{site} is the site's base URL and {page} the canonical URL. JSON-LD is output whatever the page's robots value; search engines ignore it on pages they don't index.
Schema types and properties
A profile's schema type says what its pages are about. A page type (WebPage, AboutPage, CollectionPage, ContactPage, FAQPage, ItemPage, ProfilePage and the other WebPage types) types the WebPage node itself. Any other type (Product, Article, Place, Event and so on) is a separate main entity at {page}#primary, with the WebPage as its mainEntityOfPage and it as the WebPage's mainEntity. Without a schema type, the page is a plain WebPage.
The main entity always gets a name (the title chain's value, before overrides and patterns), description, url and image (the sharing image). Articles (Article, BlogPosting, NewsArticle and so on) also get a headline and the Organization as publisher.
Map more properties in the profile, one property: chain per line:
sku: sku
offers.price: price -> rrp
offers.priceCurrency: "AUD"
offers.availability: stockStatus
author.name: authorName, "IF Architecture"
- Each chain is tried step by step, as for titles. A step in quotes is a fixed value.
defaultgives nothing (there is no site default for a schema property). - Dots make nested objects.
offers,address,geo,brand,authorandaggregateRatingare typed for you (Offer,PostalAddress,GeoCoordinates,Brand,Person,AggregateRating). - An
availabilitysuch asin stockorOUT_OF_STOCKis written as its schema.org URL (https://schema.org/InStock). - Dates are written in ISO 8601 when a field gives a date.
- Mapped properties replace the built-in ones of the same name.
Product schema doesn't need Commerce: map prices and availability from whatever fields hold them.
Adding to the graph in templates
Call seo.schema({...}) before seo(). A node whose @id matches one already in the graph is merged into it: its keys replace that node's, and a key set to null removes it. Any other node is added to the end.
{% do seo.schema({
'@id': entry.url ~ '#primary',
'@type': 'Place',
address: { '@type': 'PostalAddress', addressLocality: 'Elsternwick' },
}) %}
{% do seo.schema({ '@type': 'Event', name: 'Open house', startDate: '2026-12-05' }) %}
Changing the graph from a module
use parallelogram\seo\events\ModifyGraphEvent; use parallelogram\seo\Plugin; use yii\base\Event; Event::on(Plugin::class, Plugin::EVENT_MODIFY_GRAPH, function (ModifyGraphEvent $event) { // $event->graph is the list of nodes, after the template's; $event->element is the page's element, if any. });
The SEO field
Add the SEO field to any field layout to let editors override, per element and per site:
- the title and description (the site's patterns still apply);
- the sharing image, title and description, when they should differ for Open Graph and Twitter cards;
- robots: hide from search engines (
noindex) and don't follow links (nofollow); - leaving the element out of the sitemap;
- the canonical URL, when another page is the original. It must be an absolute
httporhttpsURL.
Empty values use the fallbacks. The field is translatable per site by default; its settings can change that. If a layout has more than one SEO field, only the first one counts. The field isn't added to GraphQL schemas yet (planned for v1.1), and its values aren't added to the search index.
Above the inputs, a preview shows the page's search result and social card as the page will output them on the live site, with the editor's unsaved changes, the profile's fallbacks and the site's patterns applied. It updates as the editor types. The title and description lengths are counted against limits set in the plugin's settings (60 and 155 characters by default), and flagged when they're over or empty. The preview works on drafts and on new entries that haven't been saved yet. For a draft, the URLs shown are the published entry's.
Templates can read the field's values as entry.seo.texts.title, entry.seo.imageId, entry.seo.indexing.noindex and so on (where seo is the field's handle).
Sharing images
With Parallelogram Images installed and a social size set defined (1200×630, crop), its variant is used. Otherwise, or for an image it can't make, a 1200×630 Craft transform is generated. Both crop around the asset's focal point.
og:image:alt and twitter:image:alt come from the asset's own alt text. Sites that keep alt text in a custom asset field instead can name it in Settings → Image alt text field (e.g. altText); it's used when the asset's own alt text is empty. Without either, the alt tags are left out.
Index pages
A profile can name the page that lists its pages, e.g. a Projects page above every project. It is picked in the profile editor with Craft's own Link field: an entry, a category, or an address (root-relative such as /projects, or absolute). It is stored as indexPage in project config in the Link field's value format, but with UIDs so it moves between environments: {entry:<uid>:url}, {category:<uid>:url}, or the address. Older values still work: an element's bare UID, a URI relative to the site (projects), and a Link reference by ID ({entry:12@1:url}). An address is matched to the element at that URI in the page's site. Breadcrumbs then run home page → index page → structure ancestors → page. The index page is taken from the most specific profile that names one (a section's before its entry type's), and is left out when it isn't live in the page's site or has no URL.
Sitemaps
Every site serves a sitemap index at /sitemap.xml, listing one sitemap per group of up to 1,000 pages:
| Group | Sitemap URLs |
|---|---|
| Each channel or structure section with URLs in the site | /sitemaps/section-{handle}-{n}.xml |
| Every single with a URL, together | /sitemaps/singles-{n}.xml |
| Each category group with URLs in the site | /sitemaps/category-{handle}-{n}.xml |
| Groups a module adds | /sitemaps/{id}-{n}.xml |
A sitemap lists live elements with URLs, in ID order, each with its last change (lastmod), its other language versions (xhtml:link, with the same x-default rule as the meta) and one image (image:image): the SEO field's image, else the first image the profile's image chain gives. The site default image is never listed. Groups with no pages are left out of the index.
An element is left out when its SEO field asks for noindex or for sitemap exclusion. This is checked in the database (the first SEO field in each field layout, read from Craft's content column), so sitemaps count and page correctly on MySQL and Postgres.
Sitemap rules in profiles
Each profile can set, in the profile form or under sitemap in project config:
- include: leave its pages out of the sitemap (
false), or list them (true, the default). - priority: 0 to 1, to one decimal place.
- changefreq:
always,hourly,daily,weekly,monthly,yearlyornever.
Each rule comes from the most specific profile that sets it: a section's before its entry types'. An entry type left out of the sitemap is left out of its section's sitemap unless the section's profile sets include itself. Priority and change frequency are omitted unless a profile sets them; search engines largely ignore both.
Commerce and other element types
There is no Commerce dependency. A module adds product types (or anything else) with Plugin::EVENT_REGISTER_SITEMAP_GROUPS:
use craft\commerce\elements\Product; use parallelogram\seo\craft\SitemapGroup; use parallelogram\seo\events\RegisterSitemapGroupsEvent; use parallelogram\seo\Plugin; use yii\base\Event; Event::on(Plugin::class, Plugin::EVENT_REGISTER_SITEMAP_GROUPS, static function (RegisterSitemapGroupsEvent $event): void { $event->groups[] = new SitemapGroup( 'products', static fn(int $siteId) => Product::find()->siteId($siteId), ); });
The group ID is lowercase letters, optionally followed by a hyphen and a handle. Profiles for product types apply to their pages' priority and change frequency as usual.
Robots, caching and other plugins
Sitemaps are served in every environment. Outside the live environment they carry X-Robots-Tag: noindex, as the pages they list do. SitemapService::indexUrl($siteId) gives the index URL for robots.txt.
Sitemaps are built on request and held in the data cache with Craft's tags for the queries that found their pages, so saving an entry purges its section's sitemaps, plus the site's tag and the profiles that set their rules. Their cache keys include project config's modification time, so a deploy that adds a section or changes a field layout starts afresh.
The sitemaps are also a craft-kit URL provider: UrlProviders::collect()->urlsForSite($siteId) lists every page in them, which Parallelogram Cache uses to warm the site.
Site crawler files
The plugin serves files from each site's root: robots.txt, humans.txt, llms.txt, /.well-known/security.txt and ads.txt ship built in, and admins can add more (app-ads.txt, .well-known/assetlinks.json and so on). Each file's path, content type and the environments that serve it are structure, kept in project config under pSeo.rootFiles, so they deploy with the code. Each site's body is an editor value in the database.
| File | Default body |
|---|---|
| robots.txt | Keeps crawlers out of /cpresources/, /vendor/, /.env and /cache/, allows everything else and links the sitemap index (Sitemap: {{ sitemapUrl }}) |
| humans.txt | The site's name, URL and language |
| llms.txt | A heading with the site's name, and its default description |
| security.txt | None |
| ads.txt | None |
A file is served when its environments include the current one (* means every environment) and the site's body, or the default it falls back to, isn't empty. Otherwise it's a 404. Saving an empty body stops a site serving a file; Use the default forgets the site's body. Served files have Cache-Control: public, max-age=3600.
Outside the live environment robots.txt always disallows everything, whatever its body or environments say:
User-agent: *
Disallow: /
Remove physical files
The web server serves a real file in the web root before PHP runs, so a web/robots.txt (or any other root file) left over from before hides the plugin's version. Delete them. The Site crawler files page warns when it finds one.
Writing bodies
Bodies are Twig, rendered in a strict sandbox of their own, not Craft's Twig environment, and printed as plain text without escaping. They can use:
siteName: the SEO site name, or the site's own namedescription: the site's default descriptionsitemapUrl: the sitemap index's URLsite.name,site.handle,site.url,site.languagecraft.entries('section', limit): the section's live entries with URLs, leaving out any whose SEO field asks fornoindexor sitemap exclusion, each withtitle,url,description(from the SEO cascade) andupdated(ISO 8601).limitdefaults to 100 and is capped at 500.
# {{ siteName }}
> {{ description }}
## Projects
{% for entry in craft.entries('projects', 50) %}
- [{{ entry.title }}]({{ entry.url }}){% if entry.description %}: {{ entry.description }}{% endif %}
{% endfor %}
Everything else is refused when the body is rendered:
| Allowed | |
|---|---|
| Tags | if, for, set |
| Filters | capitalize, date, default, e, escape, first, join, last, length, lower, replace, slice, trim, upper |
| Functions | date, max, min, range |
| Tests | defined, divisible by, empty, even, iterable, none, null, odd, same as |
| Methods | craft.entries() only |
| Properties | None on objects; the variables above are plain values |
So include, extends, import, macros, map/filter/sort with callables, constant(), source(), attribute() and raw output all fail. A body is only saved once it renders; Preview shows the output or the error first.
If a saved body fails when it's served (an entry it lists breaks it, say), dev mode shows the error. Otherwise the error is logged and the file's default body is served instead, or nothing if the file has no default or the default was what failed.
Caching root files
Rendered files are cached with the site's tag, the file's tags and the tags of any entries craft.entries() listed. Saving or resetting a body purges only that file on that site. Changing a file's project config entry, including on deploy, purges it on every site. Saving site values purges the whole site, root files included.
Tracking
Each site's trackers and Google Consent Mode defaults are set under SEO → Tracking. Add a tracker asks which one, says where to find its ID, and checks the ID before adding it; a pasted snippet works too, and its ID is kept. A tracker can be added more than once, such as two GA4 properties. Each row says what consent it waits for and where it's output. Nothing is output outside the live environment, so staging and local copies never load a tracker.
Trackers are the ParallelogramJS DeferTracker adapters, by the name ParallelogramJS registers them under:
| Name | Tracker | Id |
|---|---|---|
ga4 |
Google Analytics 4 | G-XXXXXXX |
google-ads |
Google Ads | AW-123456789 |
gtm |
Google Tag Manager | GTM-XXXXXX |
meta-pixel |
Meta Pixel | the pixel id |
tiktok-pixel |
TikTok Pixel | the pixel id |
pinterest-tag |
Pinterest Tag | the tag id |
linkedin-insight |
LinkedIn Insight Tag | the partner id |
bing-uet |
Microsoft Advertising (UET) | the UET tag id |
hubspot |
HubSpot | the hub id |
hotjar |
Hotjar | the site id |
clarity |
Microsoft Clarity | the project id |
plausible |
Plausible | the site domain, or a site-script id starting pa- |
fathom |
Fathom | the site id |
Tracking isn't saved while an ID doesn't look like its tracker's.
Adding a tracker type
A module can add a tracker to the picker, or replace a built-in one, from Plugin::EVENT_REGISTER_TRACKER_TYPES:
Event::on(Plugin::class, Plugin::EVENT_REGISTER_TRACKER_TYPES, function (RegisterTrackerTypesEvent $event) { $event->types[] = new TrackerType( 'acme', new TrackerInfo('Acme Analytics', TrackerGroup::Analytics, placeholder: 'AC-1234', where: 'In Acme, open Settings.'), new TrackerRules('AC-\d{4}', extract: ['acme\((AC-\d{4})\)'], category: 'analytics'), new TrackerSnippets(head: ['' => '<script__NONCE__ src="https://acme.test/a.js" data-id="__ID__"></script>']), ); });
The pattern is matched against the whole ID, and each extract pattern's first group is taken from a pasted snippet; both run in PHP and in the browser, so keep to syntax both understand. With ParallelogramJS, register an adapter under the same name.
With ParallelogramJS
Turn on Load trackers with ParallelogramJS only once the site registers the DeferTracker adapters; until then nothing loads. Call seo.trackingBody() at the end of the body, inside the element ParallelogramJS observes:
{{ seo.trackingBody() }}
</body>
It outputs a DeferTracker block per tracker, such as <script type="application/json" data-defer-tracker="ga4">{"id":"G-XXXXXXX"}</script>. Register the adapters the site uses in its JavaScript, as the ParallelogramJS trackers guide describes, and register gtm with its container id. With Consent Mode on, each block also names the consent category it waits for: analytics for GA4, Hotjar and Clarity, marketing for the advertising trackers and HubSpot, and none for Tag Manager, Plausible and Fathom. Give ParallelogramJS a resolver with setTrackerConsent().
Without ParallelogramJS
This is the default: Load trackers with ParallelogramJS is off unless turned on in the plugin's settings (it applies to every site). seo() outputs each vendor's own snippet in the head, with GA4 and Google Ads sharing one gtag.js loader, and seo.trackingBody() outputs the no-JavaScript fallbacks for Tag Manager, Meta, Pinterest and LinkedIn.
With Consent Mode off, they all load straight away. With it on, Google's tags follow Consent Mode, and every other vendor with a consent category waits, as ParallelogramJS trackers do. Microsoft Advertising (UET), Meta and TikTok wait too; once they've loaded, their own consent controls are kept in step with the visitor's choice, so withdrawing consent later is honoured:
- Its snippet is output inside
<template data-p-seo-consent="analytics">or"marketing", so none of it runs. - A small loader, output after them, adds a template's scripts to the page once the visitor's consent grants its category:
analytics_storageforanalytics(Hotjar, Clarity) andad_storageformarketing(Pinterest, LinkedIn, HubSpot). Each template is added once, with the loader's nonce. - Their no-JavaScript fallbacks are left out, since they would load without asking.
- Tag Manager, Plausible and Fathom have no category, so they load straight away. Tags inside a Tag Manager container follow its own consent settings.
Consent Mode
Turn on Ask for consent on the Consent tab, then choose what visitors get before they answer: Ask first, Allow analytics, ask for advertising, or (in Advanced mode) Custom states for just the consent types the site's trackers use. Countries can have their own preset. With a Google tag, seo() outputs gtag('consent', 'default', …) with the site's defaults, a wait_for_update and the country defaults, before anything that loads it. Call seo() above any other script that loads one. A consent banner updates consent by dispatching an event:
window.dispatchEvent(new CustomEvent('p-seo:consent', { detail: { analytics_storage: 'granted', ad_storage: 'denied' }, }));
Each event is merged into window.pSeoConsent, which is what releases held vendor snippets. A banner that has the visitor's earlier choice before the page's scripts run can set window.pSeoConsent = { analytics_storage: 'granted', … } first; seo() passes it to Consent Mode and the held snippets as soon as they load.
With ParallelogramJS, also call reevaluateTrackerConsent() so waiting trackers start.
Content Security Policy
Pass the page's nonce before calling seo(): {% do seo.nonce(cspNonce) %}. It's added to every script the plugin outputs, and ParallelogramJS adapters use a block's nonce for the scripts they add unless configureDeferTracker({ nonce }) gives another.
Control panel
- SEO → Site values (permission: Edit SEO values): the site name, default description and image, the patterns, and the organisation (type, name, logo, profiles elsewhere and site search URL), per site.
- SEO → Tracking (permission: Edit tracking and consent defaults): each site's tracker ids, whether ParallelogramJS loads them, and the Consent Mode defaults.
- SEO → Site crawler files (permission: Edit site crawler files): each site's bodies, with a preview. Admins can also change where a file is served, its content type and, for files they added, its path, and add or remove files. These are project config changes, so only where admin changes are allowed.
- SEO → Profiles (admins): the profiles in project config, listed by what they apply to (a section, entry type, category group or Commerce product type), with their schema type, sitemap status and warnings such as a share image list that ends at an unset site default. New profile asks what it applies to, once; the editor is named after it. They can be changed only where admin changes are allowed, and deploy with project config. The editor has three tabs:
- Page details: the title, description and share image as lists of fields to try from the top (the first with a value wins), each added from the target's own fields that suit it, dragged into order, and ending at the site default when it's set. For an Assets field, which image to use. The share image list can also hold a chosen image. A live sample beside them shows what a page of the target gets, unsaved changes included and its own SEO field left out. In Advanced mode each list can be edited as a chain (
seoTitle → title). - Structured data: the schema type, picked from schema.org's types by family, and its properties as rows, each from a field or a fixed value, with nested rows for properties that hold their own details (an offer's price). Properties Google requires or recommends for the type are listed first, a missing required one is flagged, and Add Google's recommended properties adds them in one go. In Advanced mode the properties can be edited as
property: chainlines. - Sitemap and breadcrumbs: the index page, chosen with Craft's Link field (an entry, a category or an address; not for singles), and "Include in sitemap" (Yes, No, or for a section the same as its entry type), with priority and change frequency in Advanced mode.
- Page details: the title, description and share image as lists of fields to try from the top (the first with a value wins), each added from the target's own fields that suit it, dragged into order, and ending at the site default when it's set. For an Assets field, which image to use. The share image list can also hold a chosen image. A live sample beside them shows what a page of the target gets, unsaved changes included and its own SEO field left out. In Advanced mode each list can be edited as a chain (
- Settings: the live environment, the canonical query parameters, the
x-defaultlink, the social size set, the image alt text field, and the title and description lengths the SEO field's preview counts against.
Moving values between environments
Site values and root-file bodies are database content, so they don't deploy with project config. Move them as JSON, matched by site handle:
php craft p-seo/values/export values.json php craft p-seo/values/import values.json
Default image and logo IDs are carried as they are, so they only point at the same image where asset IDs match. Each site's saved root-file bodies travel under rootFiles; importing saves the bodies in the file and leaves the others alone.
Caching
Each element's resolved meta is cached per site and carries the cache tags it was resolved under (the element, its site, the profiles that could apply to it and its index page), which Parallelogram Cache uses to purge pages. The organisation's logo is cached with its asset's tag. Saving site values or tracking purges the whole site. Adding, changing or removing a profile, including by applying project config on deploy, purges its section, entry type, category group or product type. Drafts, revisions and unsaved elements are always resolved fresh. Saving an element purges its own meta, so changes in its SEO field show straight away.
Everything cached with absolute URLs in it (resolved meta, sitemaps, rendered root files and the logo) is also keyed by the request's scheme and host and the site's base URL. On a site whose base URL is @web, a request to another host or over plain HTTP gets its own cache entry instead of filling the one HTTPS visitors are served from.
Testing behind Cloudflare
When Cloudflare terminates TLS and the origin is plain HTTP, URLs follow the request's scheme. The plugin's own caches are keyed by scheme and host, so a plain-HTTP test request can't change what visitors get, but a full-page cache in front of it can still store http:// URLs. Test origins with -H "X-Forwarded-Proto: https".
Development
composer install composer check
composer check runs Mago (format, lint and analysis) and the unit and integration suites, which need neither Craft nor a database.
Craft integration tests
The Craft suite boots a real Craft site from the sandbox project (../parallelogram-craft-sandbox), which requires this plugin through a path repository. The tests run against their own Craft install, under the pst_ table prefix in the craft_images_test database, with their own app ID so they never share cached data with the Images suite.
cd ../parallelogram-craft-sandbox
bash vendor/parallelogram/craft-seo/test/Craft/install-test-db.sh
vendor/bin/phpunit -c vendor/parallelogram/craft-seo/phpunit.craft.xml
The console commands are tested by running them as separate processes, so their controller doesn't show in coverage.
Licence
The Craft Licence. See LICENSE.md.