How to optimize your website with Sprout SEO #

Sprout SEO makes it simple to optimize your website for search engines. It's designed to allow you to set sensible defaults for each section of your website, dynamically override those defaults in the code with page specific content, and, if that's not enough, have custom control over your meta-data on entry by entry basis.

To fully understand Sprout SEO you must understand its order of priorities.

  1. Default Meta Templates
    First, create sensible default meta templates for each section of your website
  2. On-page Overrides
    Dynamically override your default meta templates with content from your entries to make your SEO more relevant and specific to the content on your page.
  3. Custom Overrides
    If a default meta template or on-page override is not enough, you can manually adjust each piece of your metadata to be exactly what you want on a per-entry basis.

In the example below, our default meta template could be used on the main page of our Sprout website. However, on a more specific page of our website, such as the Sprout SEO plugin page, we could override those defaults in the page code. If, for some reason, we wanted to get even more specific, we could override what is happening in the code by using custom overrides with our Sprout SEO fields on each individual entry. Here we have manually overridden the text for our open graph title.

Meta Tag Default Meta Templates On-page Overrides Custom Overrides Result
title Sprout Plugins Sprout SEO Sprout SEO
description Business and marketing tools SEO Plugin for Craft CMS SEO Plugin for Craft CMS
keywords craft cms, craft plugins craft seo plugin craft cms, craft seo plugin
og:title Sprout Plugins Sprout SEO Sprout SEO plugin for Craft CMS Sprout SEO plugin for Craft CMS

Managing your SEO metadata in your template #

First, let's add one line of code to the <head> tag in the header of our templates where we want our metadata to be placed.

{{ craft.sproutSeo.optimize() }}

Adding the optimize tag, prepares your header to output your meta information. By itself, nothing will be output, but we'll look at how to begin to customize your meta data and this tag will manage all of your output.

At the highest level, you can set a Global Default.

When you create a new Default Template in Sprout SEO, you will have the option to select a checkbox for "Use this default as my global fallback". You can only select that checkbox for a single Default Template and when you do, any meta value that is not defined in a more specific way, will fallback to the value you have set in your Default template when the optimize() tag is processed.

If you wish to override specific pages to use a different default template, you can begin to override the metadata on you page using the Sprout SEO meta() tag and Twig's do statement.

{% do craft.sproutSeo.meta({ default: 'default' }) %}

On an individual entry page, we can get more specific, and use the Craft entry variable to make our metadata more specific.

{% do craft.sproutSeo.meta({ 
        default: 'default',
        title: entry.title,
    description: entry.body|striptags|slice(0, 160)     
}) %}

If we want to override any of our Default Meta Template values or On-Page Override values from our entries in the Control Panel, we can setup a Sprout SEO FieldType and update our code to pass the entry ID that we want to override.

{% do craft.sproutSeo.meta({ 
        default: 'default',
        title: entry.title,
    description: entry.body|striptags|slice(0, 160)
}) %}

The craft.sproutSeo.meta() tag can update any of your meta information as your page is loading, and as long as you call it in your templates before the optimize() tag is rendered, you can nest it as deeply as you would like.

The craft.sproutSeo.optimize() function will loop through our meta values and output our meta data in html. All Sprout SEO keywords use the same value as their HTML counterparts where possible. For geo, Open Graph, and Twitter Card values we remove the period and colon in the HTML names and camel case the full name for reference. For example, geo.placename can be accessed as geoPlacename, og:title can be accessed as ogTitle, and twitter:creator can be accessed as twitterCreator.

A list of all available meta tags #

<!-- Basic SEO -->
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="robots" content="" />

<!-- Advanced SEO -->
<link rel='canonical' href='' />
<meta name='robots' content='nofollow, noarchive, nosnippet, noimageindex, noodp, noydir' />

<!-- Geographic -->
<meta name="geo.position" content=""> 
<meta name="geo.placename" content=""> 
<meta name="geo.region" content="">

<!-- Open Graph -->
<meta property='og:title' content='' />
<meta property='og:type' content='' />
<meta property='og:url' content='' />
<meta property='og:image' content='' />
<meta property='og:image:width' content='' />
<meta property='og:image:height' content='' />
<meta property='og:image:type' content='' />

<meta property='og:author' content='' />
<meta property='og:publisher' content='' />
<meta property='og:site_name' content='' />
<meta property='og:description' content='' />
<meta property='og:audio' content='' />
<meta property='og:video' content='' />
<meta property='og:locale' content='' />

<!-- Twitter Card -->
<meta property='twitter:card' content='' />
<meta property='twitter:site' content='' />
<meta property='twitter:creator' content='' />
<meta property='twitter:title' content='' />
<meta property='twitter:description' content='' />
<meta property='twitter:url' content='' />
<meta property='twitter:image' content='' />

<meta property='twitter:player' content='' />
<meta property='twitter:player:stream' content='' />
<meta property='twitter:player:stream:content_type' content='' />
<meta property='twitter:player:width' content='' />
<meta property='twitter:player:height' content='' />

An Example of Overriding all Meta Variables #

{% do craft.sproutSeo.meta({ 
    default: 'default',
    title: entry.title,
    description: entry.body|striptags|slice(0, 150),
    canonical: '',
    robots: 'noindex,nofollow',
    region: '',
    placename: '',
    latitude: '',
    longitude: '',
    ogTitle: '',
    ogType: '',
    ogUrl: '',
    ogImage: '',
    ogImageWidth: '',
    ogImageHeight: '',
    ogImageType: '',            
    ogSiteName: '',
    ogAuthor: '',
    ogPublisher: '',        
    ogDescription: '',
    ogAudio: '',
    ogVideo: '',
    ogLocale: '',
    twitterCard: '',
    twitterSite: '',
    twitterCreator: '',
    twitterTitle: '',
    twitterDescription: '',
    twitterUrl: '',
    twitterImage: '',
    twitterPlayer: '',
    twitterPlayerStream: '', 
    twitterPlayerStreamContentType: '', 
    twitterPlayerWidth: '', 
    twitterPlayerHeight: '',                                        
}) %}

Note: The id parameter is only necessary if you want to use custom overrides using the Sprout SEO fields. The rest of the parameters are optional.

SEO FieldTypes #

If you need it, Sprout SEO gives you complete control over your SEO metadata at the entry level as well. You can assign any of the SEO Fieldtypes to any section you choose.

  • Meta: Basic
  • Meta: Geographic
  • Meta: Robots
  • Meta: Open Graph
  • Meta: Twitter Card

Craft Services

Optimize Craft CMS to improve your workflows, impress your users, and acheive your business goals.

We have over 20,000 hours of Craft experience and work in close collaboration with businesses, agencies, and individuals to help make Craft CMS the best platform for you and your business. Save time and build a website that respects best practices and is designed to be scalable, maintainable, and grow with your online business and marketing needs.

Let's talk

Bring it on

  • Project Planning
  • Content Architecture
  • Data Migrations
  • Performance Optimization
  • API Integrations
  • Monthly Analysis
  • Digital Marketing Strategy

Make your life easier, your customers happy, and your business run more smoothly.

On top of our experience with the Sprout Plugin Suite, we’ve designed and built numerous custom plugins to help organizations address unique business and marketing challenges. From custom workflows to e-commerce to deep API integrations with customer databases, analytics, and cloud services, we can help build custom plugins suited to your specific needs.

Let's talk

Make things better

  • Custom Tooling
  • Improved Workflows
  • API Integrations
  • CRM Integrations
  • Email Marketing
  • Lead Generation Forms
  • E-Commerce & Donations

Spend more time focused on your business. We’ll spend the time to focus on your website.

Maintaining your website, content strategy, and customer relationships have a large impact on your business. Whether you’re a business owner, marketing director, or content author, we can help keep things running smoothly. We offer on-call and monthly retainer services to help you answer burning questions, fix annoying bugs, update software, monitor analytics, and even come running if there’s a fire.

Let's talk

We've got your back

  • General questions
  • Design changes
  • Bugfixes
  • Craft updates
  • Plugin updates
  • Coaching and Training

Build your roadmap to improve performance, usability, and identify new business opportunities.

Curious how your Craft website stacks up against all the other Craft sites out there? As a digital agency and CMS specialists who have worked with Craft since day one, our team can provide you insight into everything from content architecture to code debt. Request an audit to learn about optimization opportunities and provide a path for your business to create a better user experience and a more targeted digital strategy.

Request an Audit

Know where you stand

  • Craft Best Practices
  • Usability Audits
  • Code Audits
  • Security Audits
  • Server Audits
  • SEO Audits