Using Yoast SEO Structured Data with Genesis

Yoast SEO includes an incredibly powerful implementation of structured data, which is a tool search engines use to better understand your website.

They have extensive documentation for extending it, and many plugins already integrate with it. For instance, if you are using WP Recipe Maker for recipes on your site, it will add the appropriate recipe schema to your Yoast SEO schema.

Genesis already includes structured data, also known as schema markup. You don’t want duplicate schema on the page, so you should use one or the other.

If you’re using Genesis 3.1 or later, Genesis’ schema will automatically disable if Yoast SEO schema is active. If you’re using Genesis 3.0 or earlier, you can install my Disable Genesis Schema plugin.

Here are some ways you might customize your schema:

Customization Options

Disable Genesis schema

Genesis will only disable its schema if Yoast SEO is active and Yoast schema is enabled.

If you’re using a different plugin to add schema data, you can disable Genesis schema by adding this to your child theme’s functions.php file:

add_filter( 'genesis_disable_microdata', '__return_true' );

Plugin developers: If your plugin is outputting schema data and you’d like Genesis to automatically disable its schema, you can use the filter genesis_is_wpseo_outputting_jsonld. Here’s the relevant function from /genesis/lib/functions/seo.php.

Disable Yoast SEO schema

If you would prefer keeping Genesis’ schema data, you can disable Yoast SEO’s schema data using the following code in your child theme’s functions.php file:

add_filter( 'wpseo_json_ld_output', '__return_false' );

This is a good option if you’ve already made customizations to the Genesis schema on your site and aren’t ready to rebuild that code to support Yoast’s structured data.

But if you’re like 99% of Genesis sites that haven’t modified the default schema, you’ll be better served switching over to Yoast SEO for schema data.

Use both Genesis and Yoast SEO schema

As described below in more detail, the Genesis schema describes more elements on the page than Yoast SEO.

Yoast focuses on only the schema search engines currently care about (the primary article on the page), while Genesis tries to describe all the elements on the page, like the Header, Navigation, Sidebar, Article, and Footer.

The code below will enable Genesis schema even when Yoast SEO is active, then selectively remove the Genesis schema that relates to the main article on the page.

I don’t believe there is any SEO benefit to this approach, but I’m asked how to do it often enough that I wanted to document it.

Add this code to your theme’s functions.php file:

// Tell Genesis that WP SEO is not outputting schema
add_filter( 'genesis_is_wpseo_outputting_jsonld', '__return_false' );

/**
 * Selectively Disable Genesis Schema elements
 * @author Bill Erickson
 * @see https://www.billerickson.net/yoast-schema-with-genesis/
 */
function be_selectively_disable_genesis_schema() {

	$elements = array(
		'entry',
		'entry-image',
		'entry-image-widget',
		'entry-image-grid-loop',
		'entry-author',
		'entry-author-link',
		'entry-author-name',
		'entry-time',
		'entry-modified-time',
		'entry-title',
		'entry-content',
	);

	foreach( $elements as $element ) {
		add_filter( 'genesis_attr_' . $element, 'be_remove_schema_attributes', 20 );
	}
}
add_action( 'init', 'be_selectively_disable_genesis_schema' );


/**
 * Remove schema attributes
 *
 */
function be_remove_schema_attributes( $attr ) {
	unset( $attr['itemprop'], $attr['itemtype'], $attr['itemscope'] );
	return $attr;
}

How Genesis Schema works

Genesis uses an approach called microdata, which are data attributes attached to elements already on the page to describe those elements to search engines. For instance, your post title has itemprop="headline" to tell search engines that this is the headline of the current article.

You can run into issues if you remove elements from the page because you’re also removing the schema data that’s attached to those elements. For instance, if you remove the author name from the top of the post, you also lose the structured data saying you’re the author of this post.

You also end up with many unconnected blocks of schema. Here’s the results of the Structured Data Testing Tool on an article on my site before the code change:

How Yoast SEO Schema works

Yoast SEO uses JSON-LD which is a newer and better approach to structured data (more information).

JSON is a lightweight method to structure data to share with search engines and others. Rather than scattering your Schema data throughout the page and making the search engine assemble it (e.g. microdata), you prepare a small block of code that tells search engines exactly what they need to know in one place.

The -LD part stands for Linked Data, which means you’re able to link all of the individual schema components together. In the screenshot above you can see everything is a separate block with microdata, but with JSON-LD it would follow a hierarchical structure. The Article is part of a WebPage which is part of a WebSite.

Here’s my structured data after disabling Genesis schema and using the latest version of Yoast SEO:

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments

  1. Marlan from RV52 says

    Thanks. I’d love to see example codes of how to extend Yoast with say, a recipe, place, or event.

  2. Tania Sheff says

    Hi Bill! I was hoping maybe you can help me with a small issue I am having. I disabled Genesis schema, per your recommendations. Everything worked great, but I do have one warning when I check my Structured Data. It says: “The mainEntityOfPage field is recommended. Please provide a value if available”. Do you happen to know how to fix it? Thank you SO MUCH!

    • Bill Erickson says

      Did you customize the Yoast SEO schema with code, or are using a plugin to add the recipe schema? As far as I know, Yoast SEO does not provide recipe schema but your site is displaying it.

      Whatever is making the customization should be defining the mainEntityOnPage.

  3. Jennifer Quisenberry says

    Thank you! This was so helpful and made it a piece of cake to do. No errors found after I did it.

  4. Dhananjay Bhardwaj says

    Hi Bill. First off, thanks for this!

    Last year, I decided to disable Genesis’ Schema completely and replace that with custom Schema, like BlogPosting on posts, Website on the homepage, etc.

    Now that Yoast has improvised on the Schema part, I feel it would be nice to move to that, knowing that manual schema implementation could often be risky, for various reasons of course.

    My questions is: Do you think if I completely strip out ALL of the Genesis Schema, and only leave Yoast’s Schema there, would there be any adverse effects of it? Like Genesis has supports SD for elements like Navigation, Header, Footer, etc.

    • Bill Erickson says

      No, there shouldn’t be any adverse effects from stripping out Genesis schema. There is no SEO benefit for the schema on navigation, header, sidebar, and footer. Any schema that may have an effect on SEO is inside Yoast SEO’s schema already.

    • Bill Erickson says

      There’s no setup required. Simply install and activate the plugin – that’s it.

      Or don’t install the plugin and wait for Genesis 3.1 when this functionality will be built into core.

  5. Mark says

    My Genesis theme has schema disabled via your plugin along with Yoast SEO 11.7.

    I have manually added via WordPress Dashboard > Genesis Theme settings schema markup for Local Business (NAP details, opening hours, email, image, etc).

    When I run the site via Google Structured Data Testing Tool, I see 2 blocks of schema (WebPage and LocalBusiness). Is this the correct way to add additional schema?

  6. Delio Picciani says

    Hi Bill. Thank for the suggestions about “Using Yoast SEO Structured Data with Genesis”.
    I disabled Schema Genesis using both of two PHP that you suggested in your post, with Yoast installed of course.

    Now in the Genesis Framework update 3.0.2 in the last Genesis Changelog my attention was on two points:
    “Schema: Suppress output of Genesis schema if Yoast SEO is outputting JSON-LD markup.
    Schema: developers can disable schema with add_filter( ‘genesis_disable_microdata’, ‘__return_true’ ”

    If I will update Genesis, what to do with the added code put in the function.php.. Leaving all unaltered? For further releases of Genesis about schema issues would be better to install your plugin?
    Thank in advance for your answer

    • Bill Erickson says

      Genesis 3.1 will automatically disable the Genesis schema if Yoast SEO is outputting JSON-LD markup.

      But Genesis 3.1 is currently in beta (see here), it hasn’t been publicly released yet.

      For now, you should use either the plugin or the code shown in the post above. Once you update to Genesis 3.1, you will not need either approach, but having the plugin/code active will not have any negative effects on your site.

      My recommendation for now is to install the plugin, then when you update to Genesis 3.1 you can remove the plugin.

  7. Dave says

    Hi Bill.
    Thanks for the great info.
    I currently have your Disable Genesis Schema installed since April. I also have Yoast Premium 11.9 installed.

    I am running Genesis 3.1 – so, to be totally clear, are you saying that I can now disable/delete your Disable Genesis Scema plug-in?

    Many thanks

    • Bill Erickson says

      Yes, the functionality within this plugin is now also found inside Genesis 3.1, so the plugin is not necessary.

  8. John says

    Hi Bill,

    What if I still want make use of WPHeader, WPSideBar, WPFooter, and SiteNavigationElement with Genesis 3.1 and the Yoast plugin activated?

    Thanks alot

  9. David Mottershead says

    Dear Bill

    Have you noticed that with the new version of Genesis 3.1 with Yoast installed the datetime property is removed. It now fails to validate, but probably more importantly comment dates are now not machine readable.

    On Magazine Pro, before Yoast activation comment meta looks like this:

    October 24, 2019 at 2:53 pm

    After Yoast is activated, comment meta looks like this:

    October 24, 2019 at 2:53 pm

    I realise that once Yoast is activated, the Genesis schema markup (itemprop) is removed.

    But why is the datetime property removed ie. datetime=”2019-10-24T14:53:13+00:00″

    The comment time does not validate once Yoast is activated now.

    I realise they probably intended to remove the itemprop, but why remove datetime?

    I notice this is also happening on this site.

    • Bill Erickson says

      Why is the datetime necessary if you are not using Genesis schema? As far as I know it should only be there if you are using Genesis’ microdata-based schema, and if the itemprop has been removed that means you are not using Genesis’ microdata schema.

Leave A Reply