3

I'm converting a large EE site into Craft with the FeedMe plugin. So far it's working great. However, I've hit a speed bump. I need to import the SEO data attached to each article into Sprout SEO. When attempting to map the meta title, keyword and description data into the Sprout SEO field it only shows one destination field - the Meta:Basic field. Is it possible to import those 3 sets of data into the corresponding fields within Sprout SEO?

2 Answers 2

3

The problem you're running into is that FeedMe doesn't know how to import into custom element types; I think a special hook would need to be written.

If you use my SEOmatic plugin it has a FieldType that lets you choose what fields to pull things like the title, description, etc. from which solves this problem.

Check out the section of the wiki docs on SEO Entry Meta to see how that all works.

1
  • Hi, is there any example about how to use setContentFromPost to import data in a SEOmatic field? Commented Oct 12, 2017 at 7:18
3

In general, I feel the field types in the current version Sprout SEO (2.x) are overused. We're currently working on a big update that should help resolve this but the field types are really only needed if you are doing advanced SEO work and need to have the ability to modify your SEO values to be different than other field values that already exist on your entries.

It's much easier to manage SEO if you reuse key fields in your content. This helps content administrators focus on the content, reduces the need for duplicate data entry, and creates an effortless relationship between the keywords you are using in your content and your meta data.

My recommendation is to remove the Sprout SEO Meta Basic field from your content architecture. You can probably use the value Title field for your Meta Title, Open Graph Title, and Twitter Title. You can reuse a Summary or Excerpt field for the Descriptions across meta types. And a Featured Image field for the images.

When you are reusing the fields you already have in your content architecture, you can then setup your template code to use those values across the meta data options that fit. For example, let's say you want to use the following 2 fields for your meta:

  • entry.title
  • entry.body

With your optimize tag in your header:

{{ craft.sproutSeo.optimize() }}

You can now call the meta tag on your specific pages to build your meta:

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

This method takes a little more setup in your templates but simplifies the management of the SEO for your content editors significantly. This was the way we intended Sprout SEO to be used initially. The fields were only intended to be used for more advanced use cases. In retrospect, we've learned that many people default to trying to use the fields for SEO rather than leveraging the existing fields and using the code overrides. This adds an additional step for preparing a clean SEO workflow for your websites and in the coming version of Sprout SEO we're refactoring the way that the fields work to allow you to select the fields you wish to use for SEO in the Control Panel without the overhead of additional fields to fill in, which will also add the benefit of significantly simplifying your templates.

Taking the example above a step further, you can also reuse those same fields you started with to address Open Graph and Twitter meta data. A simple example of that would be:

{% set metaTitle = entry.title %}
{% set metaDescription = entry.body|striptags|slice(0, 160)  %}

{% do craft.sproutSeo.meta({
    title: metaTitle,
    description: metaDescription,
    ogType: "article",
    ogTitle: metaTitle,
    ogDescription: metaDescription,
    twitterCard: "summary",
    twitterTitle: entry.title,
    twitterDescription: metaDescription,
}) %}

While above I argue that importing to the Sprout SEO field type is usually not the best approach to managing your meta data, if your meta data is very unique and your project demands more customization, it appears that the FeedMe plugin has a way to map a custom field that's being imported in the Hooks Documentation on their Github repo.

You would currently need to add support for the Meta field type that you wanted to import things into, but it appears possible. If you really need to go this direction, consider reaching out to us at Sprout. We have some internal tools we use to import data into Sprout SEO and other plugins and I'd be happy to discuss options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.