Quantcast
Channel: Crunchify
Viewing all articles
Browse latest Browse all 1037

WordPress, Yoast SEO and Google Sitelinks Searchbox

$
0
0

Today I was reading Yoast’s article about Google Sitelinks Searchbox. Very interesting article and as we are using Yoast SEO on Crunchify, ideally Sitelinks Searchbox should be working out of the box.

But interestingly, so far I didn’t see Sitelinks Searchbox for Crunchify on Google Search Result Page. Also, noticed the same behavior for Yoast.com itself. That made me wonder, there must be something wrong or something I’m missing 🙁

So, I started digging further on official Google page: https://developers.google.com/search/docs/data-types/sitelinks-searchbox. Link has all detailed information and to be honest, there is no magic and it’s very simple.

By default Yoast SEO adds application/ld+json Google Schema.org to your home page and adds canonical URL for your blog.

After further testing and analysis I found a strange thing about ID attribute. Take a look at below Google Structured Data Validation tool page snapshot.

Why it’s http://www.example.com/#website?

This @id attribute has been added by Yoast SEO’s file /frontend/class-json-Id.php.

Again, as per Google’s suggestion, it’s absolutely not required.

How to fix this?

Step-1

  • Go to your admin console
  • Click on Plugins -> Editor
  • Choose Yoast SEO plugin and click Select button

Step-2

  • Search for file class-json-ld.php
  • Find below line and remove it
  • Line ==> '@id' => '#website',

Step-3

You need to do the same for Organization schema too if you have it enabled it. Just remove line $this->data['@id'] = '#organization'; too.

Have any of below related search query question, then you are at right place:

  • sitelinks search box example
  • google sitelinks search box not showing
  • sitelinks search box wordpress
  • google sitelinks wordpress plugin
  • how to get sitelinks for your site on google
  • google sitelinks generator
  • google structured data

Here are updated website code block:

public function website() {
	$this->data = array(
		'@context' => 'http://schema.org',
		'@type'    => 'WebSite',
		'url'      => $this->get_home_url(),
		'name'     => $this->get_website_name(),
	);
	$this->add_alternate_name();
	$this->internal_search_section();
	$this->output( 'website' );
}

Here are updated organization code blocks:

private function organization() {
	if ( '' !== $this->options['company_name'] ) {
		$this->data['@type'] = 'Organization';
		$this->data['name']  = $this->options['company_name'];
		$this->data['logo']  = $this->options['company_logo'];
		return;
	}
	$this->data = false;
}

That’s it. Just clean your site/blog cache and checkout your site’s home page using HTML code. Yoast SEO plugin won’t add ID attribute to Google Sitelinks Searchbox schema anymore.

NOTE: This is my best guess suggestion and workaround and hoping it to work within few weeks. There is no guarantee that this will work but I’ll keep monitoring crunchify.com’s search box in Google Search Result Page and will keep you all updated.

I’ve created an issue on Github https://github.com/Yoast/wordpress-seo/issues/6382 to get an update from plugin developer. If you have any better suggestion then I’m all in for it. Let me know in comment section.

Have a suggestion on article? Please chime in and share it as a comment.

The post WordPress, Yoast SEO and Google Sitelinks Searchbox appeared first on Crunchify.

Author: App Shah

Crunchify, LLC Logo


Viewing all articles
Browse latest Browse all 1037

Trending Articles