Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.78k stars 894 forks source link

%%excerpt%% not autogenerating snippet #6288

Closed reekes closed 4 years ago

reekes commented 7 years ago

What did you expect to happen?

Adding the %%excerpt%% variable to Titles & Meta settings should autogenerate a snippet from the content.

What happened instead?

No content in the snippet. When I go to a post to edit, in the Yoast meta box I shows %%excerpt%% in the snippet. But if I view the actual published page, there's no description for the page being added. If I manually add a snippet, that does get published.

It's the auto-generated snippet feature that's failing, and only for one specific custom post type. I have four different custom post types and it's working in all expect this one type.

How can we reproduce this behavior?

I used "WCK Post Type Creator" to quickly and easily create a custom post. All I really wanted was to change the slug for my blog posts. So I have a custom post type of "post" with rewrite slugs.

I also created three other custom posts types, but those are working.

Can you provide a link to a page which shows this issue?

Failing example: https://argonsys.com/blog/annoucing-argon-systems-product-family/

Working example: https://argonsys.com/learn-microsoft-cloud/articles/storage-spaces-direct-lab-setup/

I can code page templates, debug, etc. I just don't know where to even begin with this problem. Let me know what more I can provide.

Technical info

terw-dan commented 7 years ago

%%excerpt%% uses the excerpt field for the content. Is there anything filled out in the excerpt field?

reekes commented 7 years ago

There's nothing in the excerpt field.

Using the %%excerpt%% variable will auto-generate an except (used as the og description, copying the first characters of the content) when there is no excerpt filled in. That's what's documented, and that's how it's working in every other past or post. The problem I'm describing is specific to a custom post type, yet I have other custom post types that all work.

When there is no excerpt or snippet filled in, this is what's generated in the HTML page.

property="og:description" content="LinkedIn Facebook Twitter Google+"

You can see this in the failing example I provided

https://argonsys.com/blog/annoucing-argon-systems-product-family/

terw-dan commented 7 years ago

I've tried reproducing the problem with a custom post type, but when using %%excerpt%% it relies on the content to fallback.

It seems something is setting "LinkedIn Facebook Twitter Google+" in the excerpt field. Is this being added somewhere on the page?

reekes commented 7 years ago

Is this being added somewhere on the page?

No. Again, everything about the problem post is being done exactly as I do with all other pages and posts. There's nothing different about the problem post and the working posts from my end. I rely on the auto-generated default excerpt, and will write a custom snippet when I feel necessary.

What I'm telling you is the Yoast SEO plugin is NOT auto-generating the excerpt for this one type of post, AND it's inserting...

property="og:description" content="LinkedIn Facebook Twitter Google+"

My question, again, is how to get the Yoast SEO plugin to do the documented behavior of auto-generating the excerpt?

As I said, again, I have a few custom post types. Yoast SEO plugin is working correctly in all those other posts types except for my blog posts. I described how to reproduce what I've got.

I used "WCK Post Type Creator" to quickly and easily create a custom post. All I really wanted was to change the slug for my blog posts. So I have a custom post type of "post" with rewrite slug (set to "blog").

The "it" in your question something is setting "LinkedIn Facebook Twitter Google+" in the excerpt field is the Yoast SEO plugin.

Also, there's a bug where it's inserting "LinkedIn Facebook Twitter Google+"

Two problems with the Yoast SEO plugin.

reekes commented 7 years ago

After a lot of trial and error, I found what's triggering the bug. I'm using the Divi theme.

Creating a post with the Divi visual builder Yoast SEO plugin not auto-generate an excerpt.

To prove this I took the failing post, went to the editor and removed the Divi visual builder. Then published the post using the standard WP editor. This the Yoast SEO plugin auto-generated an excerpt.

Going back to the editor, and switching to the Divi visual builder I published the post once again. This time Yoast SEO plugin did not auto-generate an excerpt.

Therefore the bug is when using the Divi visual builder with a post (at least this is true for a custom post but probably also for a standard post).

terw-dan commented 7 years ago

Our plugin doesn't generate an excerpt, it uses the excerpt field to generate the description. If the Divi theme is adding some text in an excerpt, we will pick that up. I would suggest checking the theme and how it handles the excerpt field. If it leaves the excerpt empty, YoastSEO will be able to fallback on generating a description from the content field.

Since this isn't a bug on our side, this issue can be closed.

reekes commented 7 years ago

Closed? Really? Blaming Divi? Really? Are you familiar with the product's advertised features?

YoastSEO is documented to use the %%excerpt%% variable as:

Replaced with the post/page excerpt (or auto-generated if it does not exist)

It is being auto-generated if one hasn't explicitly provided an except. Yet when I use the Divi theme's visual builder to create the post, you're saying this isn't supported. Really?

Divi isn't adding anything. It's not creating an excerpt. What's happening is YoastSEO is failing to do the documented behavior.

You are saying the documentation is wrong if one is using the Divi theme to create the post.

Really? If I paid for this plug in would my bug reports be dismissed?

terw-dan commented 7 years ago

Since this is working when you don't use the Divi visual builder it means generating the description works like expected.

Because this bug is not something that is in our code generating a description, it is not something we can fix out our end.

reekes commented 7 years ago

You should update the documentation then. Say it doesn't support the Divi theme.

BTW - did you even try this, or are you just closing the bug without investigating it? How do you know this isn't a bug in "our code"?

Guess I'm better off knowing I shouldn't pay for this plugin, since the support is ready to dismiss bugs and blame others.

CarolineGeven commented 7 years ago

@reekes I'm sorry to hear you feel mistreated. I'm reopening this issue as we've got more compatibility issues with Divi and we should dive into this.

reekes commented 7 years ago

Thank you Caroline. I also found related problems with my Divi usage, where the og:description wasn't being added on pages, even when I had added a explicit excerpt in the Yoast admin settings. My except was added to the HTML as a meta tag for the description, but then not added as the og:description. Odd since both should be exactly the same (simply duplicated).

I stopped looking into this related problem after seeing my bug report here being dismissed. So I don't have better details for you at this moment (and going on my memory of seeing the problem).

If you're interested, I'll look into that problem further.

CarolineGeven commented 7 years ago

Thanks for your reply, @reekes! We're always interested in more details that could help us solve the problem. If you've found anything relevant, you can always let us know.

Pcosta88 commented 7 years ago

1.Add %%excerpt%% in the SEO-Titles and Metas Section

screen shot 2017-07-06 at 1 14 42 pm

2.See that %%excerpt%% appears in the preview

screen_shot_2017-07-06_at_1_13_16_pm

3.Add a Divi Text Module

screen shot 2017-07-06 at 1 13 25 pm

4.Confirm text has been added

screen shot 2017-07-06 at 1 13 31 pm

5.See no excerpt meta description appear

screen_shot_2017-07-06_at_1_14_09_pm

6.Switch to default editor on the backend and resave

screen shot 2017-07-06 at 1 16 50 pm

7.See excerpt

screen shot 2017-07-06 at 1 17 23 pm

NOTES: WordPress: 4.8 Yoast: 5.0.1 Divi: 3.0.29 ( I dont have access to the newest one but reviewing the comments/issues above it may also affect the newest version)

Pcosta88 commented 7 years ago

Please inform the customer of conversation # 206439 when this conversation has been closed.

tarfoot commented 7 years ago

This seems to be an issue with some pages I have that were built using Media Bakery's Visual Composer.

sebastiencyr commented 7 years ago

The issue is caused by Yoast SEO using strip_shortcodes() on the post content which removes everything within shortcodes. Why not use do_shortcode instead?

asteriskmmt commented 6 years ago

@cutterax is 100% correct. This is easily solved by running the the_content filter before generating the auto excerpt.

caspervoogt commented 6 years ago

I am using a theme called Charity NGO, which uses Visual Content Composer, and am having the same problems. The %%excerpt%% is not replaced by text. Even if I switch to the default editor.

@asteriskmmt " This is easily solved by running the the_content filter before generating the auto excerpt." how / where would this be done - do you mean editing the Yoast plugin code?

sebastiencyr commented 6 years ago

We use the following code, which works with any content enclosed in shortcodes. You can put this code in your functions.php or a custom plugin:

// FIX SEO incompatibility with visual composer
add_filter( 'wpseo_replacements', function( $replacements ){
    global $post;

    if( ! sizeof($replacements) && ! empty($post->post_content) ){
        $replacements['%%excerpt%%'] = wp_html_excerpt( do_shortcode( $post->post_content ), 155 );
    }

    return $replacements;
});
caspervoogt commented 6 years ago

thanks! this helped!!

Casper Voogt

casper.voogt@plethoradesign.com Plethora Design Work: (877) 515-6682 ext.2 https://www.plethoradesign.com

On Thu, Jan 25, 2018 at 2:56 PM, cutterax notifications@github.com wrote:

We use the following code, which works with any content enclosed in shortcodes. You can put this code in your functions.php or a custom plugin:

// FIX SEO incompatibility with visual composeradd_filter( 'wpseo_replacements', function( $replacements ){ global $post; if( ! sizeof($replacements) && ! empty($post->post_content) ){ $replacements['%%excerpt%%'] = wp_html_excerpt( do_shortcode( $post->post_content ), 155 ); } return $replacements;});

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Yoast/wordpress-seo/issues/6288#issuecomment-360581842, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsHWLY0dWraq7Pq3kwu_xFvmXnPpzYQks5tONxegaJpZM4LP_7z .

tarfoot commented 6 years ago

I'm guessing you could update the excerpt length to 320 -- per Yoast's article on longer meta descriptions.

adam-jones-net commented 6 years ago

I've got to work on a site that was built using the theme that runs with the CMSMasters Content Composer tool which is very similar.

The fix suggested by @cutterax works in the front-end of my site so thanks very much! However in the admin the preview of the descriptions in the Yoast metabox doesn't change and still appears with the "please provide" message. Is this going to be the same for sites with the Divi visual builder ?

Pcosta88 commented 6 years ago

User reports the same issue with %%excerpt%% affects RSS feeds.

Pcosta88 commented 6 years ago

Please inform the customer of conversation # 321441 when this conversation has been closed.

Jimmi08 commented 6 years ago

@cutterax Thank you very much.

ashkanghadimi commented 6 years ago

I have the same problem. I remembered that It was working about 2 yrs ago, but now, it's not generating automatically. So here is what I've found so far:

  1. I switched my theme to Twenty Seventeen
  2. Then I disabled All plugins except Yoast
  3. The problem still persisted, then I Installed Yoast version 5.5 and then the problem resolved.
  4. I tried to update the Yoast to latest one to make sure that is the clue, and YES, the problem occurred again.

It seems that there's sth wrong with newer version. some screenshots are representing the issue. NB: The only active plugin is Yoast with twenty Seventeen Theme. plug 5 5 8 2

Pcosta88 commented 5 years ago

Yoast is not skipping over the shortcodes when the excerpt variable is used. These shortcodes get outputted into the Snippet Preview section

Pcosta88 commented 5 years ago

Please inform the customer of conversation # 515449 when this conversation has been closed.

shendison commented 5 years ago

Watching...

stmarytx commented 5 years ago

I'm having the same problem with a custom post type I created programmatically. My CPTs individually do not have manually-created excerpts, but in Yoast settings for this specific CPT I've said to use the excerpt as the meta description.

image

According to the Yoast knowledgebase, using the %%excerpt%% variable uses the manual excerpt if one is present, or an auto-generated one if it doesn't exist. When I view the source of one of the pages, I see a notice:

<!-- Admin only notice: this page does not show a meta description because it does not have one, either write it for this page specifically or go into the [SEO - Search Appearance] menu and set up a template. -->

web1100manager commented 5 years ago

Hi,

I'm having the exact same issue as eshannon3, although my issue extends to regular pages and posts as well. Does using %%excerpt%% automatically generate an excerpt?

Pcosta88 commented 4 years ago

Issue happens with WPBakery

1. Add a text module with WPBakery, see Yoast webworker tool identify the text.

Excerpt Variable Added

3

Webworker Picks up text

2

2 No description tag outputted

4

Tested with WP: 5.3.2 Yoast: 12.7.1 WPBakery: 6.0.3 and 6.1

WorkAround

Possible workaround would be to add the code here https://github.com/Yoast/wordpress-seo/issues/6288#issuecomment-360581842 into your theme's function.php file

1. Add Code to file

Screen_Shot_2020-01-03_at_2_00_15_PM

2. See excerpt appear as meta description and og description in source code.

Screen Shot 2020-01-03 at 2 01 00 PM
Pcosta88 commented 4 years ago

Please inform the customer of conversation # 572918 when this conversation has been closed.

Djennez commented 4 years ago

I've discussed this issue with the product owners and we've decided to close it for now.

While we're aware of the way that 3rd party pagebuilders use shortcodes to build their pages, for the moment we're not going to parse shortcodes for the excerpt. We might revisit the idea of a wider integration with pagebuilders in the future, and the parsing of shortcodes might be included in that project. But due to the nature of shortcodes, they might bring more harm than good if we decide to parse them out of the box. So for now I'd advise anyone with this issue to give the filter of @cutterax a try (see this comment). Please do take care with this implementation and make sure you know what you're doing.

jeremymoore commented 4 years ago

I've having a similar issue to that described by eshannon3. Our theme is not using page builders, however we have a CPT with a template that relies on custom fields (ACF) and doesn't make use of the_content() where Yoast might typically auto generate from.

In our theme, we use add_filter( 'get_the_excerpt', '....') which does the work of returning a custom excerpt when otherwise empty.

Are you using this filter when auto generating an excerpt in the Yoast plugin? Why would my filter not be used successfully returning our custom excerpt?

This is true in the following conditions

Xriuk commented 3 years ago

We use the following code, which works with any content enclosed in shortcodes. You can put this code in your functions.php or a custom plugin:

// FIX SEO incompatibility with visual composer
add_filter( 'wpseo_replacements', function( $replacements ){
    global $post;

    if( ! sizeof($replacements) && ! empty($post->post_content) ){
        $replacements['%%excerpt%%'] = wp_html_excerpt( do_shortcode( $post->post_content ), 155 );
    }

    return $replacements;
});

This solution works partially and "breaks" my site, since the excerpt happens to appear multiple times (description, open graph, ...) the Divi shortcodes get parsed multiple times, and the blocks counter gets incremented each time, so at the end my rendered page is wrong, instead of a class ".et_pb_column_1" I get ".et_pb_column_25" cause the shortcodes got "rendered" multiple times, there should be a way of caching it once...

EDIT: I found a solution, counters can be reset in Divi, here's the updated code

// FIX SEO incompatibility with visual composer
add_filter( 'wpseo_replacements', function( $replacements ){
     global $post;

     if( ! sizeof($replacements) && ! empty($post->post_content) ){
         $replacements['%%excerpt%%'] = wp_html_excerpt( do_shortcode( $post->post_content ), 155 );
         ET_Builder_Element::reset_element_indexes("", true);
         ET_Builder_Element::reset_styles();
     }

     return $replacements;
 });