Support » Plugin: Yoast SEO » [Plugin: WordPress SEO by Yoast] Error in looking for keywords in page URL

  • OC2PS


    I have a non-English site and so a lot of “special characters” – ó ü ö ú ő é á ű í etc in article titles. WP strips the accents and converts these to a e i o u etc. when generating the URL.

    But when I try to check via WordPress SEO by Yoast, it seems that the URL doesn’t have the keyword because the URL slug actually has the keyword but with accents/ diacritics stripped.

    My understanding is that Google considers with and without diacritics as the same. Shouldn’t this plugin too?

Viewing 4 replies - 1 through 4 (of 4 total)
  • claudemlandry


    I had the same problem.
    I solved the problem by adding the following code in 2 files.

    *** function testFocusKw() in file wp-seo-metabox.js ***
    Replace the function with this code:

    function testFocusKw() {
    // Retrieve focus keyword and trim
    var focuskw = jQuery.trim( jQuery('#yoast_wpseo_focuskw').val() );
    focuskw = focuskw.toLowerCase();

    var postname = jQuery('#editable-post-name-full').text();
    var url = wpseo_permalink_template.replace('%postname%', postname).replace('http://','');

    p = new RegExp("(^|[ \s\n\r\t\.,'\(\"\+;!?:\-])"+focuskw+"($|[ \s\n\r\t.,'\)\"\+!?:;\-])",'gim');
    str = focuskw.replace(/\s+/g,"[-_\\\//]");
    //CML remove accents from slug
    var from = "àáäâèéëêìíïîòóöôùúüûÿñçÀÂÇÉÈÊËÙ";
    var to = "aaaaeeeeiiiioooouuuuyncAACEEEEU";
    for (var i=0, l=from.length ; i<l ; i++) {
    str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
    p2 = new RegExp(str,'gim');

    if (focuskw != '') {
    var html = '<p>Your focus keyword was found in:
    html += 'Article Heading: ' + ptest( jQuery('#title').val(), p ) + '
    html += 'Page title: ' + ptest( jQuery('#wpseosnippet .title').text(), p ) + '
    html += 'Page URL: ' + ptest( url, p2 ) + '
    html += 'Content: ' + ptest( jQuery('#content').val(), p ) + '
    html += 'Meta description: ' + ptest( jQuery("#wpseosnippet .desc span.content").text(), p );
    html += '</p>';

    *** function score_url() in file class-metabox.php ***
    I added this code after the declaration of variable needle

    $needle = $this->strip_separators_and_fold( $job["keyword"] );
    // Remove Accented UTF-8 Characters
    $search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u,À,Â,Ç,É,È,Ê,Ë,Ù");
    $replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u,A,A,C,E,E,E,E,U");
    $needle = str_replace($search, $replace, $needle);

    I have made a modification to the last version of the plugin for those who don’t want to edit code.

    claudemlandry your modification uses JavaScript and PHP for something that can be achieved solely modifying the javascript code. It might work but it isn’t very clean.

    For the french speaking users here is an explanation on how you should update the plugin.

    I have submitted a comment to worpdress seo plugin forums, and a patch to Yoast. I don’t know when he is going to integrate it.

    I hope you find it useful.

    Thanks. The javascript modification has been rollout in version 1.3.3

    The PHP modification is required for the “Page Analysis” Tab.

    It turns the following yellow warning :
    The keyword / phrase does not appear in the URL for this page. If
    you decide to rename the URL be sure to check the old URL 301
    redirects to the new one!
    to this green message:
    The keyword / phrase appears in the URL for this page.


    You are totally right, sorry for my comment then. I will have a look at the code to see if the modification for the “Page analysis” can be deployed easily.

    It would be nice to inform from within the plugin that the diacritics word is not equivalent to the un-diacriticized one (Google thinks of them as different words). Although it is good thing to have the two versions because people may search both: with and without diacritics.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Error in looking for keywords in page URL’ is closed to new replies.