Fixing duplication in HTML title element for WordPress with Yoast SEO installed

I was having a problem in WordPress for my blog where the title contained duplicate values, like “John’s blogJohn’s blog”.

The fix for me was to edit wp-content/themes/twentyeleven/header.php and disable a bit of the output, as shown below. I basically just added an if ( false ) to disable the code which caused the duplicate content.

This seems to effectively mean that Yoast SEO is in charge of the titles now. You can configure separately the homepage, posts, and pages titles in the Yoast SEO settings. I configure mine in Yoast SEO Settings / Content Types like this:

Homepage
Site title Separator Tagline
Posts
Title Separator Site title
Pages
Title Separator Site title
<title>
<?php
  // Print the <title> tag based on what is being viewed.
  global $page, $paged;

  wp_title( '|', true, 'right' );

// 2024-07-14 jj5 - OLD: I removed this because wp_title() (above) does everything that needs to be done.
if ( false ) {
  // Add the site name.
  bloginfo( 'name' );

  // Add the site description for the home/front page.
  $site_description = get_bloginfo( 'description', 'display' );
  if ( $site_description && ( is_home() || is_front_page() ) ) {
    echo " | $site_description";
  }

  // Add a page number if necessary:
  if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
    /* translators: %s: Page number. */
    echo esc_html( ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) ) );
  }
}
?>
</title>

New WordPress plugins for the blog

I have been rolling out CloudFront for a few of my domains, including blog.jj5.net.

In order to integrate CloudFront with WordPress I used the W3 Total Cache plugin.

And in order to set the <link rel=”canonical”> element I used the Yoast SEO plugin.

At one point I had a problem with garbled content in my browser. Looked like the browser was trying to display compressed content as text. But now I can’t reproduce, so hopefully whatever the issue was it is now fixed…