Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

05. SEO Entry Meta

Andrew Welch edited this page Apr 18, 2019 · 12 revisions

No Maintenance Intended

DEPRECATED

This Craft CMS 2.x plugin is no longer supported, but it is fully functional, and you may continue to use it as you see fit. The license also allows you to fork it and make changes as needed for legacy support reasons.

The Craft CMS 3.x version of this plugin can be found here: craft-seomatic and can also be installed via the Craft Plugin Store in the Craft CP.

SEO Entry Meta

SEOmatic provides a FieldType called SEOmatic Meta that you can add to your Sections. It allows you to provide meta information on a per-entry basis. SEOmatic will automatically override any Site Meta or Tempalate Meta with Entry Meta if an entry that has an SEOmatic Meta field is auto-populated by Craft into a template.

This also works with Categories and Craft Commerce Products that have an SEOmatic Meta field attached to them.

If you add an SEOmatic FieldType to an existing Section that already has entries in it, you'll need to re-save the Section to populate the newly added SEOmatic FieldType with data. You can do this via Settings → Edit My Section → hit Save.

If any fields are left blank in an Entry Meta, those fields are pulled from the SEO Site Meta / SEO Template Meta.

You can also dynamically change any of these SEO Meta fields in your Twig templates, and they will appear in the rendered SEO Meta.

  • Main Entity of Page - The Main Entity of Page is a more specific, additional type that describes this entry. This additional JSON-LD structured data entity will be added to your page, more specifically describing the page's content. It is accessible via the seomaticMainEntityOfPage Twig variable, should you wish to modify or add to it.
  • SEO Title - This should be between 10 and 70 characters (spaces included). Make sure your title tag is explicit and contains your most important keywords. Be sure that each page has a unique title tag.
  • SEO Description - This should be between 70 and 160 characters (spaces included). Meta descriptions allow you to influence how your web pages are described and displayed in search results. Ensure that all of your web pages have a unique meta description that is explicit and contains your most important keywords.
  • SEO Keywords - Google ignores this tag; though other search engines do look at it. Utilize it carefully, as improper or spammy use most likely will hurt you, or even have your site marked as spam. Avoid overstuffing the keywords and do not include keywords that are not related to the specific page you place them on.
  • SEO Image - This is the image that will be used for display as the webpage brand for this entry, as well as on Twitter Cards and Facebook OpenGraph that link to this page, if they are not specified. The image must be in JPG, PNG, or GIF format.
  • SEO Image Transform - The image transform to apply to the Site SEO Image.
  • Canonical URL Override - The canonical URL is automatically set to the entry's URL. This allows you to override the canonical URL if you need to; this can be a path or a fully qualified URL. Just leave it blank for the canonical URL to be set automatically.
  • Twitter Card Type - With Twitter Cards, you can attach rich photos and information to Tweets that drive traffic to your website. Users who Tweet links to your content will have a “Card” added to the Tweet that’s visible to all of their followers.
  • Twitter Card Image - This is the image that will be used for display on Twitter Cards for tweets that link to this entry. If no image is specified here, the Site SEO Image will be used for Twitter Cards instead. The image must be in JPG, PNG, or GIF format.
  • Twitter Card Image Transform - The image transform to apply to the Twitter Card Image. Twitter recommends: 120 x 120 pixels minimum size, 1:1 aspect ratio, 1mb max size for Summary Card images, and 280x150 pixels minimum size, 1.86:1 aspect ratio, 1mb max size for Summary Card with Large Image images.
  • Facebook OpenGraph Type - Adding OpenGraph tags to your website influences the performance of your links on social media by allowing you to control what appears when a user posts a link to your content on Facebook.
  • Facebook OpenGraph Image - This is the image that will be used for display on Facebook posts that link to this entry. If no image is specified here, the Site SEO Image will be used for Facebook posts instead. The image must be in JPG, PNG, or GIF format.
  • Facebook OpenGraph Image Transform - The image transform to apply to the Facebook OpenGraph Image. Facebook recommends: 1200 x 630 pixels minimum size, 1.9:1 aspect ratio, 8mb max size.
  • Robots - The robots meta tag lets you utilize a granular, page-specific approach to controlling how an individual page should be indexed and served to users in search results. Setting it to a blank value means 'no change'.

The SEO Title, SEO Description, and SEO Keywords fields can include tags that output entry properties, such as {title} or {myCustomField} in them.

You can use any Craft environmentVariables in these fields in addition to static text, e.g.:

This is my {baseUrl}

In addition to being able to hold custom data that you enter manually, you can also set the Source that SEO Title, SEO Description, SEO Keywords, and SEO Image SEOmatic Meta fields to pull data from to an existing field in your Entry.

SEO Image only can pull from an existing Assets field, while SEO Title, SEO Description, and SEO Keywords can pull from Text, Rich Text, Tags, and Matrix fields. If you pull from a Matrix field, SEOmatic goes through and concatenates all of the Text & Rich Text fields together (this is useful for SEO Keywords generation).

The SEO Keywords field also allows you to extract keywords automatically from an existing field in your Entry via the Keywords From Field Source option.

SEOmatic Meta FieldTypes also have default settings that allow you to control what the default settings should be for each meta field, and whether they can be changed by the person editing the entry.

Entry Meta Properties in your Templates

If you're using an SEOmatic Meta FieldType in your entries, you can also access the properties of it in your templates. This is useful, for instance, if you're iterating through craft.entries and want to be able to access the meta properties of each entry in the loop.

Assume that we have an SEOmatic Meta FieldType with the handle seoMeta in our template, we can do things like:

{% for newsItem in craft.entries.section('news').limit(10) %}
	{{ newsItem.seoMeta.seoTitle }}
	{{ newsItem.seoMeta.seoDescription }}
	{{ newsItem.seoMeta.seoKeywords }}
	{{ newsItem.seoMeta.seoImage }}
{% endfor %}

In addition, you can do:

{% set assetID = newsItem.seoMeta.seoImageId %}

...to get the seoImage's AssetID, and you can also do:

{% set newsJsonLD =  newsItem.seoMeta.getJsonLD(newsItem) %}

...to get the Main Entity of Page JSON-LD array for the entry, which you can then manipulate, or output via SEOmatic's Twig function:

{{ newsJsonLD | renderJSONLD }}