The default WordPress search functionality is certainly lacking in areas. Although changes were made in 2013 to improve it, there are still a few areas where WordPress could use some help. It is, however, relatively easy to improve WordPress search by adding a few pieces of code. Here, I’ll list some of the methods you could use to make WordPress search better.

Optimize your site for search & social media and keep it optimized with Yoast SEO Premium »

Yoast SEO: the #1 WordPress SEO plugin Info

Sort by relevance

In older versions of WordPress, search results were sorted by date and not much else. Because this is (at the very least) annoying for websites with a lot of posts, WordPress core introduced a patch that would change the way search results are sorted.

The changes are as followed:

  • Results with a full sentence match in the post title are listed first.
  • Search results that include all search terms in the title, but not a full sentence match, are listed next.
  • Results including any search terms in the title, but not all search terms or a full sentence match, are listed next.
  • Finally, search results that include a full sentence match in the post content come last. Within each group, results are further sorted chronologically by publication date.

Improving the interface

Excerpts in search results by WordPress are not exactly great. Unlike Google, the WordPress search omits emphasis of the keyword if it found matches. Luckily, you can alter parts of the search results and add this feature.

Preparing your theme

In your theme, look for the file that outputs the search results. In this example, it’s a file that I’ve created manually, called /template-parts/post/content-search.php in a Twenty Seventeen child theme. This file is a copy of content-excerpt.php that exists in the same directory.

Next, look for the file called search.php in the theme’s main directory and look for the following line of code:

get_template_part( 'template-parts/post/content', 'excerpt' );

Change this to the following:

get_template_part( 'template-parts/post/content', 'search' );

By making these changes, you’ll ensure that WordPress will use your custom template instead of the default one. Time to add the actual code that will be doing the emphasizing!

Open up functions.php and add the following function:

/**
 * Adds emphasis to the parts passed in $content that are equal to $search_query.
 *
 * @param $content The content to alter.
 * @param $search_query The search query to match against.
 *
 * @return string The emphasized text.
 */
function emphasize( $content, $search_query ) {
    $keys = array_map( 'preg_quote', explode(" ", $search_query ) );
    return preg_replace( '/(' . implode('|', $keys ) .')/iu', '<strong class="search-excerpt">\0</strong>', $content );
}

What this function does, is taking the passed content and emphasize every occurrence of the word(s) passed in $search_query and return the text. The class that was added to the <strong> tag can be used to further style the end result (if you want to).

Adding emphasis in the title

Now that we’ve gone through the steps to setup your custom template parts adding emphasis in the title is relatively easy to do.

Go into your newly created content-search.php and find the line that looks like:

the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );

and replace it with the following:

$title = emphasize( get_the_title(), get_search_query() );

echo sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">%s', esc_url( get_permalink() ), $title ) . '</a></h2>';

That’s all there is to it!

Adding emphasis in the excerpt

You’d expect that adding emphasis to the excerpt can’t be much harder than adding it to the title. Sadly, this is not the case. With excerpts, WordPress automatically concatenates a “Continue reading” link to the end. You’d be fine as long as the search phrase doesn’t exist in the slug of the post, but most of the time if you’re looking for specific keywords, it will be present in the slug. This results in a broken “Continue reading” link.

To overcome this, you’ll have to temporarily overrule some default WordPress behavior.

First, add the following to your functions.php:

/**
 * Creates a custom read more link.
 *
 * @return string The read more link.
 */
function modify_read_more_link() {
    return ' <a class="more-link" href="' . get_permalink() . '">Continue reading</a>';
}

The above code will be called to ensure we have a workable “Read more” link.

This part hooks into the function that creates the actual excerpt and adds our emphasis and custom “Read more” link.

/**
 * Allows for excerpt generation outside the loop.
 *
 * @param string $text  The text to be trimmed
 * @return string       The trimmed text
 */
function custom_trim_excerpt( $text = '' ) {
    $text = strip_shortcodes( $text );
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]&gt;', $text);

    $excerpt_length = apply_filters('excerpt_length', 55);

    $trimmed = wp_trim_words( $text, $excerpt_length, '' );

    if ( is_search() ) {
        $trimmed = emphasize( $trimmed, get_search_query() );
    }

    return $trimmed . modify_read_more_link();
}
add_filter('wp_trim_excerpt', 'custom_trim_excerpt');

Sadly, there’s no elegant alternative for this. Hopefully, someday, a filter will be created that can be called instead of having to overrule large portions of the trim function.

Tracking searches

There are a few options to track the search queries that visitors have entered, but we recommend using Google Analytics for this. To get started with tracking searches, please go through the following steps:

  1. Login to Google Analytics.
  2. Click on Admin (gear on the bottom-left).
  3. Under View, click on View Settings
  4. Scroll down until you find the Site Search Tracking toggle and turn it on.
  5. In the Query Parameter field, enter s. This is the default query parameter that is added by WordPress when using the search function.
  6. Click Save

If your website is heavily dependent on categories and allows users to use them to refine their searches, Google Analytics gives you the ability to add tracking on this too. For more information on this subject, you can read Google’s documentation on search tracking in this article.

Alternatives

If your website has grown a lot and you want to supercharge your search, it might be wise to look at a few alternatives. One that we use at Yoast is Algolia. This platform contains a ton of features to make search even better. Some features are: Typo-tolerance, support for synonyms, filters and support for 100+ languages. It also includes integrations with WordPress!

Become a technical SEO expert with our Technical SEO 1 training! »

Technical SEO 1 training Info

Another alternative is Amazon CloudSearch. It offers similar features to Algolia, and you can enable autoscaling if you think your website needs it. However, ACS does not provide you with an integration out of the box, so you’ll have to write your implementation or look for a WordPress plugin in the Plugin Directory. At the time of writing, there are only two plugins present; CloudSearch and Lift.

Yes, you can improve WordPress search

As you could read, the WordPress search has improved over the years. Despite this, it still lacks in some aspects. Luckily you can improve it by adding some extra code in your child theme or take it to the next level by using external services such as Algolia and Amazon CloudSearch. Good luck!

Read more: ‘Internal search: why and how’ »

The post How to improve WordPress search appeared first on Yoast.

With the release of Yoast SEO 5.5 comes a great new feature: SEO roles. A site admin can now determine in the backend of WordPress who gets access to the various settings and features of Yoast SEO. This makes for a more fluid and flexible access protocol for different kinds of users on a site. It is no longer a one-size-fits-all solution, but a more tailored one. SEO roles make Yoast SEO even more powerful for every type of user. Here, we’ll explain why these roles are so awesome.

Optimize your site for search & social media and keep it optimized with Yoast SEO Premium »

Yoast SEO: the #1 WordPress SEO plugin Info

Managing user roles in Yoast SEO 5.5

It’s always been a challenge to use Yoast SEO in a larger site environment. As an admin, you’d have to choose between offering users full access to the plugin or just access to the SEO post editor part. That means a regular user couldn’t use the redirects manager, for instance, and had to ask an admin for help every time he or she wanted to add, change or delete redirects. We’ve seen it happing here at Yoast as well. Of course, there’s a whole range of possible permissions in between. Yoast SEO now introduces two new roles that make this a lot easier to manage: the SEO manager and SEO editor, in addition to the admin who determines who gets to see what.

Roles and capabilities

Roles in Yoast SEO consist of one or more capabilities, like:

  • managing options (this gives you full access),
  • managing redirects,
  • editing advanced metadata,
  • access to the bulk editor.

The SEO editor, for instance, can now make redirects, but cannot change the settings of the plugin or access the advanced metadata editor of Yoast SEO. This way, the SEO editor has more access than a regular user, but less than the SEO manager who can manage settings as well. If you use a permission or role manager plugin for WordPress like Justin Tadlock’s excellent Members plugin, you get even more fine-grained control over the capabilities within Yoast SEO. This way, you can mix and match capabilities in any form you’d like.

In Yoast SEO Premium, we’ve also added the capability to manage redirects without having to be an administrator. By activating this, users within a specific role get full access to the redirects manager. No longer do site managers have to be swamped with redirects requests by site editors, they can manage those themselves. Personally, I like that a lot. By adding some magic code to the plugin, the redirects manager now shows up in the WordPress sidebar menu, even if your Yoast SEO menu is hidden by default. How cool is that?

yoast seo 5.5 filter

Managing your site has never been easier

The SEO roles in Yoast SEO make it incredibly easy to give more people working on your site access to the features and settings they need, without granting them full access. Does your site editor need to edit advanced metadata? No? Block it in Yoast SEO. Does he or she need to manage redirects and do large-scale SEO optimizations with the bulk editor? Great, grant him or her access to these parts of the plugin. You can do this and more – all from the admin dashboard of Yoast SEO!

Read more: ‘Yoast SEO 5.5: Introducing SEO roles’ »

The post Managing access to Yoast SEO with SEO roles appeared first on Yoast.

In WordPress, content can be grouped using categories and tags by default. WordPress calls these groups taxonomies. When you are serious about your content and have a lot of it, it will pay off to create other groups as well. By creating these custom taxonomies, you’re making your life as a content writer easier. More importantly, you’ll structure your website to your best effort for your visitors. They’ll be able to locate content that’s relevant to them and find related content more easily. This article will dive into the use of custom taxonomies.

Hierarchical versus non-hierarchical

WordPress introduced the concept of tags in version 2.3. As described by Wikipedia, a tag is ‘a non-hierarchical keyword or term assigned to a piece of information.’ This means WordPress has had a hierarchical way of classifying information (categories), and a non-hierarchical way of organizing information (tags) since version 2.3. As far back as 2006 (!), people were discussing the fact that tags are not categories. The problem is that WordPress calls them both ‘taxonomies,’ but that’s not entirely correct. The word taxonomy assumes a hierarchy of sorts, as explained on another Wikipedia page

Learn how to structure your site well with our Site structure training! »

Site structure training$ 99 - Buy now » Info

With version 2.8, WordPress introduced custom taxonomies. Or actually, allowed easier access to the already available backend for custom taxonomies. These custom taxonomies can be either non-hierarchical (e.g. ‘tag’-like) or hierarchical (e.g. ‘category’-like). But for now, only the non-hierarchical taxonomies benefit from the smooth integration. These are more like actual taxonomies though, as they add a kind of hierarchy to the tag structure.

Let me give you an example: you could have a ‘People’ and a ‘Places’ taxonomy. Say, you write a new post and decide to add a keyword in the ‘People’ taxonomy. By doing that, you’re saying that it’s a keyword (or tag, if you want) of the type ‘People,’ so it is hierarchical in a way. But it also makes the keyword that much more informative, as it adds another layer of information.

Some years ago, Roy Huiskes made this visual for us by making a graphical explanation of the subject:

custom taxonomies

Fun fact: That People taxonomy section in the image above would include some more branches nowadays.

You can imagine using this for locations, or employees on a company site, but also writers on a book site, destinations on a travel site, etcetera. It groups items in a convenient way, both for maintenance and your visitors.

Custom taxonomies in WordPress

Adding custom taxonomies in WordPress isn’t that hard. To manually register a taxonomy, you can use the register_taxonomy() function. Most WordPress developers have probably used this one time or another, right?

WordPress.org has an example of how to approach this for a People taxonomy:

function people_init() {
	// create a new taxonomy
	register_taxonomy(
		'people',
		'post',
		array(
			'label' => __( 'People' ),
			'rewrite' => array( 'slug' => 'person' ),
			'capabilities' => array(
				'assign_terms' => 'edit_guides',
				'edit_terms' => 'publish_guides'
			)
		)
	);
}
add_action( 'init', 'people_init' );

This piece of code adds a meta box to your WordPress post edit screens, that looks like the tag box. It even works in the same way. I’m not a fan of tag clouds, but yes, in theory, you could even create a cloud for your new taxonomy. For a more in-depth explanation, check this post by wpmudev.org (2016).

These custom taxonomies can be public and private, which also makes them extremely useful for internal grouping of elements as well. I can imagine grouping VIP users, social influencers; you name it. 

Become a technical SEO expert with our Technical SEO 1 training! »

Technical SEO 1 training$ 199 - Buy now » Info

Note: (Custom) Taxonomies and Gutenberg

As Matt Cromwell describes, “Gutenberg is the future of content in WordPress. It will deliver the elegance of Medium but with far more power and flexibility of layouts and content types”. But Gutenberg is currently in development, and 99% of WordPress users probably won’t see any of it until it’s finished.

However, just last week, my colleague Tim added an issue to the WordPress/Gutenberg Github repo: Gutenberg shows private taxonomies in Category and Tag lists. Just dropping this here as a note, as I am sure the development team fixes this before releasing Gutenberg to the public. But if you are test-driving Gutenberg on a live site, and you are using custom taxonomies somewhere on that site, it could be something to check. Just to be sure!

How are you using custom taxonomies?

So, in conclusion, custom taxonomies can be very useful. If you have loads of content and want to create order, for both yourself and your users, you could use them.

That leaves me with two questions: Are you using custom taxonomies and if yes, how did you add these to your site? I’m looking forward to your answers in the comments!

Read more: ‘Using category and tag pages for SEO’ »

Advanced Custom Fields, or ACF, is one of the most popular WordPress plugins to date. It makes it possible to turn WordPress into a full-blown, custom-made content management system. How? By providing an easy way to add and manage custom fields. To use the content analysis of Yoast SEO in these custom fields, you need a plugin: ACF Content Analysis for Yoast SEO. As of today, two existing ACF glue plugins will come together in one official plugin. Here, we’ll shine a light on the open source driven development of this new ACF plugin.

Optimize your site for search & social media and keep it optimized with Yoast SEO Premium »

Yoast SEO for WordPress pluginBuy now » Info

Why use Advanced Custom Fields?

Like the name says, the Advanced Custom Fields plugin, built by Elliot Condon, makes it easier to add custom fields to any WordPress site. While custom fields may sound boring on their own, they are used to extend WordPress. What’s more, people use them to build tailored solutions to, often, complex problems. Developers love these and use custom fields to develop new and exciting products on top of WordPress. By using custom fields, you can turn WordPress into a professional CMS that accomplishes all your needs perfectly.

What does the ACF Content Analysis for Yoast SEO plugin do?

The ACF Content Analysis for Yoast SEO plugin makes it possible for Yoast SEO to work inside custom fields. By using this plugin, you can use the SEO and readability analysis features of Yoast SEO to check your writing and SEO score, even if they live in a complex custom field.

Marcus Forsberg built the original ACF Content Analysis for Yoast SEO plugin. We later forked it to build our own solution. However, both plugins had trouble keeping up with the developments. Some time ago, we started a collaborative effort to make one, well-maintained, official ACF plugin for Yoast SEO. Viktor Fröberg, Marcus Forsberg, Thomas Kräftner and the great team at Angry Creative, helped us to merge two different ACF glue plugins and redevelop these into ACF Content Analysis for Yoast SEO. The team will update this plugin on a regular basis and offer continued support for ACF.

Version 2.0 of the plugin, available as of today, is rewritten from the ground up. It supports ACF 4 and 5. It offers stellar performance and supports more custom fields than ever.

Building something better, together

This is a collaborative effort. It is high time to put a spotlight on some of the team members that made sure two incredible WordPress plugins can start working together seamlessly.

Thomas Kräftner, freelance web developer:

“When Yoast SEO 3.0 came out I had a problem: I had just finished a site for a client that relied heavily on the now removed server-side analysis of content. Of course, the client wasn’t happy that all the work he paid for was wasted.

So we sat down and talked. I explained to them that they wouldn’t be the only ones with that problem. Instead of letting people reinvent the wheel, again and again, we should better make one generic solution. I proposed that my client would only pay a part of my development cost. In exchange, we’d make a completely free and open source plugin. And guess what – they thought this was a great idea!

I then also contacted Yoast, and at WordCamp Europe 2016 we agreed that they would also join in and help me maintain and support that plugin. It was a busy year, so it took until WCEU17 and also bringing Angry Creative on board to finally get us where we are today: The release of a true community built plugin.”

Viktor Fröberg, web developer at Angry Creative:

“At Angry Creative, we mainly do WordPress and WooCommerce development. As such, we often bump into both generic problems and specific problems that we fix by doing plugins. We also try to fix WordPress / WooCommerce core issues, but doing plugins helps us get solutions out there sooner rather than later.

We try to talk to our clients about the importance of open source and why this is valuable for them. A lot of our clients’ problems are shared problems, and by contributing our solutions to the community, our clients get free development time from other developers in the long run as they help improve the plugin. This pooling of resources benefits everyone.

This ACF Yoast SEO integration plugin was just like that. It was born out of a common need that almost all of our clients had. We’ve maintained it, and our clients have benefited from it. With the help of the awesome Thomas Kräftner and the Yoast crew the plugin is now better than ever, and together we’ll continue to improve it so that users can build their next big thing using WordPress with ease.”

Omar Reiss, CTO at Yoast:

“A collaboration like this is very dear to our heart. We get an incredible number of requests to add support for other plugins. At Yoast, we prefer such integrations to be backed by the community. We do our best to make it easy for third-party plugin developers to integrate with Yoast SEO. Whenever users request an integration, we mostly reach out to third-party plugin maintainers and offer our help and assistance in integrating with Yoast SEO. This works out well in many cases.

In this case, Marcus, Thomas and the folks at Angry Creative all separately leveraged the opportunity to create an integration between ACF and Yoast SEO. We happily brought everyone together to work on one integration to rule them all, reviewed, endorsed and distributed by Yoast, developed by the community.”

Open source driven development

The new ACF Content Analysis for Yoast SEO plugin is a solid piece of open source driven development. Ten developers from Sweden, Austria, and The Netherlands identified problems with the current implementation and stepped up to fix it. Working together with a fantastic team from around Europe and a shared open source mindset has made it possible for them to deliver fabulous work.

Open source is at Yoast’s heart. We try help others reach for the stars while continually improving our work. Projects like the ACF Content Analysis for Yoast SEO plugin give us the opportunity to learn from others and to contribute to the ever-expanding WordPress universe.

Download the plugins and tell us what you think! Thanks for supporting our work.

Read more: ‘Why there’s only one model: the open source model’ »

Our mission is ‘SEO for everyone’. We keep that in mind, in everything we do. But what do we mean by it? And why is it our mission? In this post, I’d like to explain Yoast’s mission.

A little bit of history

To understand why we pursue this mission, we’ll have to go back in history. Let’s start in 2006: Joost de Valk was building SEO plugins because he strongly believed that everyone could benefit from the SEO knowledge he had collected in his work for large agencies. As a WordPress fanboy, he could quickly translate his technical SEO skills into a useful plugin for WordPress. 

New to SEO? Learn the Basics of SEO in our Basic SEO course »

Basic SEO training$ 199 - Buy now » Info

The WordPress SEO plugin, which was rebranded to Yoast SEO later on, got an enormous amount of users. What’s more, Joost received an overwhelming number of support requests and was unable to handle those, as he was still working for an agency as well. At that point, Joost decided to start his own company. Selling premium plugins and doing a little bit of consultancy enabled him to further invest time and resources into the free Yoast SEO plugin as well. This allowed us to improve the quality and features of our products, and also resulted in a growing company. Moreover, it meant we could further define our mission.

WordPress’ mission and Yoast’s mission

The mission of WordPress is to democratize publishing with open-source GPL (General Public License) software. Yoast’s mission builds on WordPress’ mission, just as Yoast’s software is an extension of the software of WordPress. Everybody can create a website using WordPress. However, not everyone is able to rank in the search engines. In some niches, the search results are dominated by large companies with even larger marketing budgets. The Yoast SEO plugin, combined with the SEO knowledge Yoast shares, enables small entrepreneurs to compete with these large companies.

A ‘fair’ chance in the search results

We believe the web will benefit from all people having an equal chance in the search results. We would love for great new ideas and inventions to spread over the world. And great ideas don’t always come from large agencies but are created everywhere around the world. That’s why we believe that every idea should have a fair chance in the search results. WordPress and Yoast SEO cover most of the technical SEO challenges of a website. But to seriously compete with the big boys, every website owner still faces content SEO challenges. In our blog posts, we explain to our audience how to write awesome and SEO-friendly content and how to set up a decent site structure. Using the Yoast SEO plugin and reading our posts should help everyone to have a fair chance in the search results. That’s what ‘SEO for everyone’ is all about.

Making money and maintaining the mission

Pursuing our mission doesn’t mean we’re not making any money while doing so. On the contrary: the company Yoast is thriving. The money we make enables us to keep on pursuing our mission. We continue to tweak and improve our plugins and we write more and more articles about SEO. Making money makes pursuing ‘SEO for everyone’ easier. We can have a bigger impact. And, it allows us to contribute more and more to WordPress core.

The premium version of Yoast SEO has some practical features, which will make SEO a lot easier. However, all essential features you need to have that fair chance in the search engines, are available and will remain in our free plugin. Our online courses are powerful to quickly learn about (one or multiple aspects) of SEO. But all the SEO information you need is also available in our many blog posts. It’s important to us that everyone – even if you haven’t got much money to spend – can benefit from our SEO products.

Read more: ‘Victory of the Commons’ »

Today we’re releasing Yoast SEO 5.2. In this brand new version you’ll find some feature enhancements, accessibility improvements and a couple of bug fixes. In addition to that, we’ve laid some groundwork that will help us make Yoast SEO work well with the plugins our users use most. Read about all the improvements here!

Accessibility

Web accessibility is something we always urge website owners to think about and improve. As we can’t let our own products fall behind, we regularly work on the accessibility of the plugins we develop. This time, we scrutinized the accessibility of the onboarding wizard of Yoast SEO and improved it so everyone will be able to use it well. 

Optimize your site for search & social media and keep it optimized with Yoast SEO Premium »

Yoast SEO for WordPress pluginBuy now » Info

Redirects for private posts

The redirects manager of Yoast SEO Premium is one of the features we’re most proud of. It makes creating redirects – and therefore preventing 404s – so much easier, and helps site owners to be less dependent of developers. As of this release, we’ve added an enhancement to this feature. From now on, if you trash a post that’s set to private, Yoast SEO Premium will also ask if you want to redirect the old url to a new one. 

Compatibility

One thing that keeps challenging plugin developers like us is to make plugins work with all the different plugins that our users use. There are so many plugins out there – not even to mention the various combinations of plugins that exist. To improve the compatibility of our plugins, we’ve added tracking to find out which other plugins our Premium users have installed. This will help us tremendously in making Yoast SEO work flawlessly on more WordPress installs. For the same reason, we’re tracking which PHP version our user’s websites are running on.

Speaking of PHP, if your site is running on PHP version 5.3 or lower, you couldn’t have missed the notice to urge you to move to a newer version since our 4.5 release. Does this WHIP notice keep annoying you? Then we have some good news for you. You can now dismiss the notice. After 4 weeks it will pop up again though, as we still believe upgrading to a newer PHP version is the best way to go.

That’s about it. Go update to 5.2 and enjoy this brand new version of Yoast SEO!

Read more: ‘Why every website needs Yoast SEO’ »

WordPress was built by the community. In just a few incredibly productive years, it grew to become the most popular CMS in the world, and all of us in the WordPress Community played a role in the evolution and development of WordPress. Together, we made it into the popular powerhouse it is today. If there was one thing that made it possible, it was the open source philosophy. Just like WordPress, Yoast was born from an open source world. In this interview, Joost de Valk shares his views on a topic dear to his heart.

Joost began his journey into the open source world many moons ago. As a contributor to the WebKit project, which built a layout engine for web browsers, he saw how a group of like-minded people could go up against mainstream, rich companies. WebKit’s small team made waves with their product. Different browsers adopted it and it helped them to hold their own against the incredible power of Internet Explorer. Joost says: “We were unbelievably efficient. I discovered very early on that it was better to build something together than on your own.” 

New to SEO? Learn the Basics of SEO in our Basic SEO course »

Basic SEO training$ 199 - Buy now » Info

A passion for open source

Talk to Joost about open source and his eyes light up. Open source formed him – it shaped his thoughts and visions. Even now, as CEO of a successful company, he’d still choose open source as the business model every time. Joost: “If I had to start over, I’d do a million things differently. But I would choose open source again in a heartbeat. I actually do think it’s better to create together. Take those design agencies that develop bespoke CMS’s. Why? It’s nonsense. It leads to vendor lock-in and that is horrible. There’s only one model: the open source model.”

‘‘If I had to start over, I would choose open source again in a heartbeat ’’

Running a business with an open source mindset is better than keeping everything behind closed doors. Joost: “Why should a school build their own site when there are hundreds of schools with the same requirements and questions? Join hands to make it manageable and cheaper. Just think how much the government could save if they used open source everywhere.”

“To me,” says Joost, “open source is a combination of community, not just friends, and a shared responsibility to find solutions to problems together. Take WordPress for example, collectively we are fixing the problem of publishing to the web. Other projects tackle different problems in the same way, together. This is how society should function; when we set our minds to it, we can achieve anything if we combine our efforts.”

David vs. Goliath

Joost sees open source as a David vs. Goliath struggle: “It’s money versus community. A lot of money versus no money. As a community-driven CMS, WordPress continuously has to figure out how to go up against large-scale commercial efforts. But, in spite of all that money, WordPress continues to grow like wildfire. We’ve reached critical mass and it will only go up from here.”

While WordPress grows, its community continues to expand. According to Joost, the community is diversifying at a rapid rate: “It’s not just developers anymore – the project attracts a wide range of people, from designers to writers. People are willing to invest loads of time into it. Just look at all those WordCamps around the world; all of them are organized by people from all walks of life.”

Open source politics

In theory, open source may sound like the perfect way to get something done, but oftentimes, good-old politics can cause everything to grind to a halt. “The political games are no fun,” Joost says. “It’s a community and therefore pretty diffuse. It takes time to reach a consensus. It’s hard to navigate the waters when there’s no one actually in charge. You have to figure out where decisions are being made and try to be there to influence them. That’s when you find out that not having anyone in charge can make it harder.”

‘‘It takes a lot of time and effort to develop a tool like Yoast SEO’’

Yoast now and in the future

Yoast as a company was built on open source and this philosophy continues to play a big part in its future plans. The Yoast SEO plugin is now spreading its wings, moving to other open source platforms like Drupal, TYPO3 and Magento. But Yoast has to sell something to make money, so in our case it’s a Premium version and other products, like services and education – aspects Joost wants to expand: “In the future, I’d love to be able to give away my plugins for free and generate enough income from our services and education platform. But, that moment is not yet in sight.”

Making money on open source seems strange and contradictory to the openness of open source. Yet, to pay nothing towards the development of products you use every day feels wrong as well. Joost: “It’s almost as if people think it’s rather easy to develop something for WordPress and that it doesn’t cost anything. That’s not true of course. It takes a lot of time and effort to develop a tool like Yoast SEO. Think about it, the readability analysis in Yoast SEO took about six man-years to develop. We could have put it in the Premium version, but we thought about the impact it would have if we gave it away for free. So we did. Come to think of it, I’ve never thought about taking something out of the free version of Yoast SEO to make people pay for it.”

Read more: ‘Yoast WordPress core contributions ’ »

Back in 2012, Twitter introduced a system called Twitter Cards which allows site owners to display enhanced tweets on their websites using a syntax very similar to that of OpenGraph. Thanks to this new system, Twitter can show nicer looking tweets, including ones containing media such as images, audio and video.

How does it work?

As mentioned in the introduction, Twitter Cards make use of a very similar syntax to that of OpenGraph. Twitter has some properties that are specific for their platform which you can see in the following snippet:

<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@yoast"/>
<meta name="twitter:creator" content="@michielheijmans"/>

The twitter:card property is required and defines the type of card you want to show. You have four flavors here: summary, summary_large_image, app and player. What the difference is between all these different cards can be found in the documentation.

Both twitter:site and twitter:creator are optional and point to the Twitter account of the website publishing the content and the author.

Optimize your site for search & social media and keep it optimized with Yoast SEO Premium »

Yoast SEO for WordPress pluginBuy now » Info

OpenGraph

When it comes to parsing URLs, images and descriptions, Twitter makes use of existing og: properties. You can overwrite these og: properties with Twitter specific ones, but most of the time this isn’t something you’d want. If your goal is to display completely different information on Twitter, then these tags allow you to override default behavior.

There’s one thing to take into account when using both the Twitter and OpenGraph options. Twitter uses name to specify the attribute whereas OpenGraph makes use of the property attribute. Take this into account if you plan on manually implementing Twitter Cards.

Implementing Twitter Cards

As with other meta tags, you need to add the Twitter tags in the <head> of your website and ensure that the values are set properly on a per-page basis. This can quickly becomes an unwieldy task for a blog, so we built a feature that generates the proper meta tags for you.

Twitter Card settings in Yoast SEO

Twitter Card input field in Yoast SEO

Want to change the look of the Twitter Card for a specific post or page? Just use the form on the Social tab. Here you can tweak specific properties to your liking.

Additionally, our Premium plugin contains Social Previews which display what the Twitter Card will eventually look like based on the current page or post:

twitter cards in yoast seo premium

Twitter Card: Preview your Twitter post with Yoast SEO Premium

Twitter Cards are a great (visual) addition and can help increase traffic to your website!

Read more: ‘SEO basics: how to use social media’ »

To help your blog gain more readers, you can make use of social buttons which allow your current readers to share interesting posts on their social media accounts. But how should you go about implementing them? In this post we’ll explain how we’ve done this at Yoast and will give you some pointers on how to get started.

Optimize your site for search & social media and keep it optimized with Yoast SEO Premium »

Yoast SEO for WordPress pluginBuy now » Info

What are social buttons?

For those who don’t know what social buttons are: They’re the buttons that you’ve seen around the internet that are usually placed somewhere below a blog post that allow readers to share articles on various social media platforms. This is great for gaining extra exposure and thus also getting more traffic to your website.

At Yoast, our social buttons look as follow:

Social Buttons

How did you implement these social buttons in WordPress?

Now you might be wondering about how these buttons were implemented. Your initial thought might be that this was added with some kind of plugin. However, at Yoast we decided to add it to our theme. This gives us extra control in how we style and display things. Of course we could have decided to add these buttons to a plugin, but the added benefit would be minimal for us.

We’ve decided to place the code for the social buttons in a template partial. This way we can easily embed it throughout the website without having to drastically edit template files or having to embed the buttons manually per post.

Here’s a basic example of how we implemented a social button for Facebook. Note that not all the code is actual production code and has been replaced with psuedo-code to make implementation easier to understand.

<?php
// File: <theme_folder>/html_includes/partials/social-share.php
function facebook_social_button() {
$article_url = get_article_url(); // Psuedo-code method to retrieve the article's URL.
$article_url .= '#utm_source=facebook&utm_medium=social&utm_campaign=social_buttons';

$title = html_entity_decode( get_og_title() ); // Psuedo-code method to retrieve the og_title.
$description = html_entity_decode( get_og_description() ); // Psuedo-code method to retrieve the og_description.
$og_image = get_og_image(); // Psuedo-code method to retrieve the og_image assigned to a post.

$images   = $og_image->get_images();
$url = 'http://www.facebook.com/sharer/sharer.php?s=100';
$url .= '&p[url]=' . urlencode( $article_url );
$url .= '&p[title]=' . urlencode( $title );
$url .= '&p[images][0]=' . urlencode( $images[0] );
$url .= '&p[summary]=' . urlencode( $description );
$url .= '&u=' . urlencode( $article_url );
$url .= '&t=' . urlencode( $title );
echo esc_attr( $url );
}
?>
<div id="social-share">
<div class="socialbox">
<a rel="nofollow" target="_blank" data-name="facebook" aria-label="Share on Facebook" data-action="share" href="<?php facebook_social_button(); ?>">
<i class="fa fa-facebook-square text-icon--facebook"></i>
</a>
</div>
</div>

The above code could be used in a similar fashion for other social media platforms, but it can vary greatly in terms of URL structure. We advise you look at the documentation of your desired platforms to ensure compatibility.

To include these social buttons in your blog posts, open up single.php in your theme’s folder and paste the following snippet where you want the buttons to appear:

<?php get_template_part( 'html_includes/partials/social-share' ); ?>

That’s it! If you don’t want to collect interaction data from these buttons, then this is all you need. If you want interactions to be tracked, then read on.

Tracking Interaction with Social Buttons

Having nicely styled social buttons in your website is one thing, but tracking the actual interactions with them would be even better.
At Yoast, we use JavaScript to ensure the tracking of the social media sharing is done correctly so we can easily see what social media platforms are popular among our readers.

The code for this is relatively simple and depends on the Google Analytics Tracker being properly implemented into your website. Assuming this is the case, the following code will be of great help:

jQuery( document ).ready( function( $ ) {
	$( '.socialbox a' ).click( function( e ) {
		e.preventDefault();
		
		if ( typeof __gaTracker !== "undefined" ) {
			__gaTracker( 'send', 'social', $( this ).data( 'name' ), $( this ).data( 'action' ), document.querySelector( "link[rel='canonical']" ).getAttribute( "href" ) );
		}
	});	
});

Get the most out of Yoast SEO, learn every feature and best practice in our Yoast SEO for WordPress training! »

Yoast SEO for WordPress training$ 99 - Buy now » Info

The above JavaScript snippet passes in some of the extra information we passed along to the anchor tag. This extra information can be identified by the data- prefix and is retrieved by calling $( this ).data( [...] ). This method allows us to easily extend the social-share div and add more buttons.

If you want more information on how Google tracks this information, you can read about it here.

Conclusion

As you can see, it’s not very difficult to add social buttons to your blog. Even tracking them in Google Analytics has become a breeze compared to past implementations.

All that’s left is to go and implement the buttons and allow your readers help promote your posts. Good luck!

Read more: ‘Social media optimization with Yoast SEO’ »

Today marks the release of the next version of our flagship WordPress plugin: Yoast SEO 4.4. In Yoast SEO 4.4 you’ll find many small changes and a couple of new features that make it even easier to work with the plugin. In this release post, we’ll give a brief overview of the changes that we’ve made, starting with Yoast SEO Premium.

New features in Yoast SEO Premium

If you’re an avid user of Yoast SEO and Google Search Console, you’ve probably connected these together so that they can work in tandem. Your crawl errors will show up in Yoast SEO so you can work on them from there. It was always possible to redirect 404 error pages using a 301, but with Yoast SEO 4.4 you can now use every type of redirect that Yoast SEO supports. These include 301, 302, 307, plus the 410 and 451 redirects. This makes it even easier to tell crawl bots exactly what should be done with the specific content.

You can find the second cool new feature in the internal linking tool. Yoast SEO Premium shows you the links that have already been added to the text. You can quickly discern the different links because they have a different icon, namely a checkmark. Of course, you’re still free to copy that link if you need to add it to the text again.

Optimize your site for search & social media and keep it optimized with Yoast SEO Premium »

Yoast SEO for WordPress pluginBuy now » Info

Changes in Yoast SEO 4.4

Besides fixing a number of bugs, we’ve been working on some enhancements to improve the flow of the plugin. To start off, we’ve improved the styling of tables, so they are viewable on mobile. In addition to that, we’ve moved the option to disable the keyword and content analysis from the general tab to the features tab.

The newest release of Yoast SEO is now live, so head on to your WordPress install and hit that update button. We hope you enjoy this new release. If you need more information on this release, you can check out the changelog on WordPress.org. Thanks!

Read more: ‘Why every website needs Yoast SEO’ »