3

I have the theme Hatch and I can't figure out how to change the meta-description of the home-page. It is not an actual page, it is the default view for posts.

Have searched everywhere for an answer but really can't figure it out. I have downloaded the plug-in SEO by Yoast, but only seem to be able to change the meta-description on pages and posts...?

1
  • You can use the WordPress General Settings for name and tagline otherwise the plugin includes fields for the home page. Jan 7, 2014 at 19:29

4 Answers 4

3

You do not need to add Yoast if you only want to add meta tags to the homepage. Just some minor editing will save you on performance.

You can use the is_home() function.

Insert this to your header.php:

<?php if (is_home()) { ?>
 <meta name="description" content="Your description for homepage..." />
<?php } else { ?>
 <meta name="description" content="Description for other pages..." /> 
<?php } ?>
1
  • 1
    very useful code
    – prosti
    Oct 6, 2016 at 9:53
1

You can also do by this

 <?php
the_post();
if (  is_home()  ) { ?>
<meta name="description" content="YOUR DESCRIPTION" />
<?php } elseif (is_single()) { ?>
<meta name="description" content="<?php the_excerpt(); ?>" />
<?php } ?>

this will set different description for home and other.

1

I had the same issue, and since this post is one of the first results that comes up in Google, I wanted to share the solution that I found.

The code that Christine provides is good, but the problem is that you shouldn't generally edit the header.php file directly, since your changes would be erased when you update the theme.

The solution is to insert the code into your own plugin, and to use an action hook in order to insert the description into the header:

<?php    
function add_meta_home() { 
    if (is_home() || is_front_page()) { ?>
        <meta name="description" content="Lorem ipsum dolor sit amet."/>
        <?php
        }
    }
add_action('wp_head', 'add_meta_home');
?>

The use of (is_home() || is_front_page()) ensures that the meta description displays for your website's homepage, regardless of how it's configured.

-1

For WordPress SEO (by Yoast) - it's under titles and meta - there will be a home tab. The All in one SEO plugin gives the option to autogenerate or customize the description

I made an SEO video using Yoast: https://www.w3bdesign.ca/free-wordpress-seo/

2
  • In the latest Yoast there is no "Titles and meta" option, any other way? Oct 24, 2016 at 19:29
  • 1
    @PetarVasilev you need to enable Advanced Settings in Yoast. Dec 4, 2017 at 15:06

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