category URL's and SEO ranking

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

category URL's and SEO ranking

Haluk Karamete
When you keep the category base ( that is you don't remove it by a
plug in) WordPress does allow you to browse to your 2 level deep
category in two different ways as the example below would demonstrate
it.

say, your category has a top level item "MULTIMEDIA" and a child under
it called VIDEO.

Visually, we are talking about a situation like this;

Category taxonomy

multimedia
    video
    audio
topics
    science
    politics
Well, you may get to that child (video) in the following 2 different ways;

yoursite.com/category/multimedia/video or yoursite.com/category/video

The point here is that WP brings you to the exact same page,
regardless of which URL has been used, and there are no redirects here
neither, so both URL's remain on the visitor's browser as is just like
it was requested at the first place. And with either URL, the
resulting content is identical.

That's a hateful situation by Google.

Google punishes such sites cause your web site got the same exact
content appearing under 2 different URL's. ( This is of course when
you happen to use both URLs. ) Sure, Nobody would want to do that
deliberarely but sometimes you end up with that. And this question is
all about that case.

Let's say, you wanted to pick the simpler URL for your VIDEO category
and you want to stick to that only. Basically, you want the URL to be

yoursite.com/category/video

This is easy to achieve when you use the custom menu feature that
comes with WordPress where you can specify a URL for that particular
custom menu item of yours. So, when visitors click on the VIDEO link
on the custom menu, they end up coming to

yoursite.com/category/video

No problems so far...

But as soon as they pick a post out of that category, and they end up
coming to a post where the post's meta data displays things like
"CATEGORIZED in" or "TAGGED by" etc, they will be exposed to the
alternative URL for that VIDEO category.

So, if a user clicks on the VIDEO link in the "Categorized in" area,
the URL that they will end up with would be

yoursite.com/category/multimedia/video

And with that, there goes your SEO ranking.

My question is what techniques do you use here so WordPress always and
always use one single URL, the URL you defined in the custom menu.

I thought, category slugs could do this, but when I checked it, slug
feature allows me to change only the category term in the URL, not the
path to it.

If it were to give me a choice like

video slug: /category/video

I would be done.

But that choice is not available at this moment. When you do that, you
end up with the following slug instead

categoryvideo

That's because / is not a valid character for a slug.

Please suggest an alternative way to tell WordPress to stick to
/category/video at all times.

Before suggesting the obvious, ( well, just skip the 'multimedia' and
make the 'video' a top level cat. ), let me say that that suggestion
won't work for our situation.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: category URL's and SEO ranking

Mike Little-4
There are a number of ways to solve this problem, which, by the way,
doesn't merit such strong words as "hateful" and "punishes". Google's
ranking algorithm is just that: an algorithm, it doesn't hate or punish.

Anyway, there is a filter 'term_link' which WordPress passes the generated
term link and the elements used to construct it. So you can reconstruct it
in the way that you want.

For example, add this code to your theme's functions.php or a plugin

add_filter( "term_link", 'my_term_link', 10, 3 );
function my_term_link( $termlink, $term, $taxonomy) {
 // check this is a category link, and we are using permalinks
if ( ( 'category' == $taxonomy ) && ( false === strpos( $termlink, '?' ) )
)  {
 global $wp_rewrite;
$termlink = $wp_rewrite->get_extra_permastruct( $taxonomy );
 $termlink = str_replace( "%$taxonomy%", $term->slug, $termlink );
$termlink = home_url( user_trailingslashit( $termlink, 'category' ) );
 }
return $termlink;
}

This will work for category links in the custom menus too (assuming you
don't use custom links there)

Another solution (which feels like a better solution to me) would be to add
a canonical link to the header of the category archives page. This code
will do that.
add_action( 'wp_head', 'category_rel_canonical' );
function category_rel_canonical() {
if ( !is_archive() )
return;

global $wp_the_query;
$term = $wp_the_query->get_queried_object();
 $taxonomy = $term->taxonomy;
$t = get_taxonomy($taxonomy);
if ( $t->rewrite['hierarchical'] ) {
 $link = get_term_link( $term, $taxonomy );
echo "<link rel='canonical' href='$link' />\n";
 }
}

If you run the two lots of code together then you will always get the
non-hierarchical canonical link. But then you might as well not use
hierarchical categories at all.


Mike
--
Mike Little
http://zed1.com/
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: category URL's and SEO ranking

Haluk Karamete
Mike,

Thank you for the code. I have only a handful of cats, ( 20 so to speak ).
And not all of them needs this kind o shortening. For example, a URL like

site.com/explore/region/north-america

, though longer, is better than

site.com/explore/north-america.

Ofcourse, what's better or not is debatable but the point is for some
cats, the site owner decides to go with the full url and in some the
shorter one.

Having said that, would then the following adjustment to your code be
OK to go with;

add_filter( "term_link", 'my_term_link', 10, 3 );
function my_term_link( $termlink, $term, $taxonomy)
{
    // check this is a category link, and we are using permalinks
    if ( ( 'category' == $taxonomy ) && ( false === strpos( $termlink,
'?' ) ) )
    {
        if(0):
            global $wp_rewrite;
            $termlink = $wp_rewrite->get_extra_permastruct( $taxonomy );
            $termlink = str_replace( "%$taxonomy%", $term->slug, $termlink );
            $termlink = home_url( user_trailingslashit( $termlink,
'category' ) );
        else:
            $taxonomy_term = $taxonomy . "_" . $term;
            switch($taxonomy_term):
            case  "3_10": //alternatively, I can go here
"category_video" too right? Assuming the filter is called like that?
                    //overwrite the WP computed URL alone when
taxonomy ID is 3 and term id is 10
                    $termlink = "/category/video";
                    break;
            default:
                    //leave WP computed URL alone
                    break;
            endswitch;
        endif;
    }
    return $termlink;
}

Also, I could not understand the part " ( false === strpos( $termlink,
'?' ) ) ) "
When you check for the query string existence, what do you make of
that? Does your original code uses the full URL ( that is
/category/multimedia/video as opposed to /category/video ) when the
URL happens to have a QS attached to it? Did I get this part wrong?



On Sun, Jun 17, 2012 at 3:15 AM, Mike Little <[hidden email]> wrote:

> There are a number of ways to solve this problem, which, by the way,
> doesn't merit such strong words as "hateful" and "punishes". Google's
> ranking algorithm is just that: an algorithm, it doesn't hate or punish.
>
> Anyway, there is a filter 'term_link' which WordPress passes the generated
> term link and the elements used to construct it. So you can reconstruct it
> in the way that you want.
>
> For example, add this code to your theme's functions.php or a plugin
>
> add_filter( "term_link", 'my_term_link', 10, 3 );
> function my_term_link( $termlink, $term, $taxonomy) {
>  // check this is a category link, and we are using permalinks
> if ( ( 'category' == $taxonomy ) && ( false === strpos( $termlink, '?' ) )
> )  {
>  global $wp_rewrite;
> $termlink = $wp_rewrite->get_extra_permastruct( $taxonomy );
>  $termlink = str_replace( "%$taxonomy%", $term->slug, $termlink );
> $termlink = home_url( user_trailingslashit( $termlink, 'category' ) );
>  }
> return $termlink;
> }
>
> This will work for category links in the custom menus too (assuming you
> don't use custom links there)
>
> Another solution (which feels like a better solution to me) would be to add
> a canonical link to the header of the category archives page. This code
> will do that.
> add_action( 'wp_head', 'category_rel_canonical' );
> function category_rel_canonical() {
> if ( !is_archive() )
> return;
>
> global $wp_the_query;
> $term = $wp_the_query->get_queried_object();
>  $taxonomy = $term->taxonomy;
> $t = get_taxonomy($taxonomy);
> if ( $t->rewrite['hierarchical'] ) {
>  $link = get_term_link( $term, $taxonomy );
> echo "<link rel='canonical' href='$link' />\n";
>  }
> }
>
> If you run the two lots of code together then you will always get the
> non-hierarchical canonical link. But then you might as well not use
> hierarchical categories at all.
>
>
> Mike
> --
> Mike Little
> http://zed1.com/
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: category URL's and SEO ranking

Mike Little-4
On 17 June 2012 14:18, Haluk Karamete <[hidden email]> wrote:

> Mike,
>
> Thank you for the code. I have only a handful of cats, ( 20 so to speak ).
> And not all of them needs this kind o shortening. For example, a URL like
>
> site.com/explore/region/north-america
>
> , though longer, is better than
>
> site.com/explore/north-america.
>
> Ofcourse, what's better or not is debatable but the point is for some
> cats, the site owner decides to go with the full url and in some the
> shorter one.
>
>
It actually sounds like some of your categories should be a different
taxonomy.



> Having said that, would then the following adjustment to your code be
> OK to go with;
>
> add_filter( "term_link", 'my_term_link', 10, 3 );
> function my_term_link( $termlink, $term, $taxonomy)
> {
>    // check this is a category link, and we are using permalinks
>    if ( ( 'category' == $taxonomy ) && ( false === strpos( $termlink,
> '?' ) ) )
>    {
>         if(0):
>             global $wp_rewrite;
>            $termlink = $wp_rewrite->get_extra_permastruct( $taxonomy );
>            $termlink = str_replace( "%$taxonomy%", $term->slug, $termlink
> );
>            $termlink = home_url( user_trailingslashit( $termlink,
> 'category' ) );
>         else:
>            $taxonomy_term = $taxonomy . "_" . $term;
>


You can't do this, the term is an object that is passed. And neither is a
number. The taxonomy is a string.
And my code only operates when the taxonomy is 'category' so you wouldn't
need to test for it again.

If you are thinking of numbers for these things you are thinking wrong: the
numbers are incidental and really only relevant to the database. Yes,
WordPress code uses ID's of various objects, but that is only because they
are convenient keys into the database record.



>            switch($taxonomy_term):
>            case  "3_10": //alternatively, I can go here
> "category_video" too right? Assuming the filter is called like that?
>                    //overwrite the WP computed URL alone when
> taxonomy ID is 3 and term id is 10
>                    $termlink = "/category/video";
>


Not sure why you haven't used the call to home_url() and backslashit()


                   break;

>            default:
>                    //leave WP computed URL alone
>                    break;
>            endswitch;
>        endif;
>    }
>    return $termlink;
> }
>
> Also, I could not understand the part " ( false === strpos( $termlink,
> '?' ) ) ) "
> When you check for the query string existence, what do you make of
> that? Does your original code uses the full URL ( that is
> /category/multimedia/video as opposed to /category/video ) when the
> URL happens to have a QS attached to it? Did I get this part wrong?
>
>
>
The code I wrote is checking whether pretty permalinks are turned on, if
they are not, the url will include a query string, and therefore the
manipulation does not need to be done.


Mike
--
Mike Little
http://zed1.com/
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: category URL's and SEO ranking

David Law-4
In reply to this post by Haluk Karamete
I tend not to have multiple level deep categories for another SEO reason,
what's in the child cat is copied in the parent cat and if you aren't
careful (where you have only one child cat everything is repeated in the
parent as well) that will generate duplicate content.

Anyway, think you've found a WordPress SEO problem that doesn't exist in the
real world, in theory yes, in reality no.

WordPress by default links to the child cats with the parent cat in the URL,
there shouldn't be links to both of these URLs-

yoursite.com/category/multimedia/video
yoursite.com/category/video

There should only be links generated by WordPress to
yoursite.com/category/multimedia/video

Yes, you or others could link to either URL but why would that occur? I've
been using WordPress for over 5 years and I didn't know both load the same
content until 10 mins ago. If there's no links Google won't find both URLs.
If for some reason both are indexed Google is quite good (though not
perfect) at determining the best URL, will normally use the URL that has
most backlinks which would be yoursite.com/category/multimedia/video

This site http://www.free-recipe.co.uk/ uses the structure you are concerned
about, had that structure for years, it's got over 200,000 pages indexed
(the site has 130,000 posts) in Google, 27 parent cats and 300ish child cats
in those parent cats. All the parent cats but one are alphabetical, A
Recipes etc...

Didn't do extensive tests, but child cats like
http://www.free-recipe.co.uk/free-recipes/a-recipes/appetizer-recipes are
not indexed in the other URL format.

Google site search use this format
site:site:http://www.free-recipe.co.uk/free-recipes/appetizer-recipes
site:http://www.free-recipe.co.uk/free-recipes/bread-recipes

Basically removing the parent category part of the URL shows no results as
I'd expect event though the URLs do load content.

Feel free to check as many child cats this way, there's 300 to choose from.
Either WordPress and no one has linked to the alternative URL format or
Google has combined the results to the correct URL, either way nothing to
worry about.

You are also over estimating duplicate content damage, in the vast majority
of cases where a site inadvertently had duplicate content (very easy to do
in WordPress monthly archives can be a copy of the home page for example)
Google combines the results into the best URL without the need for canonical
URLs or 301 redirects.

David
--
http://www.stallion-theme.com/ Stallion All In One WordPress SEO Theme

-----Original Message-----
From: Haluk Karamete
Sent: Saturday, June 16, 2012 9:53 PM
To: [hidden email]
Subject: [wp-hackers] category URL's and SEO ranking

When you keep the category base ( that is you don't remove it by a
plug in) WordPress does allow you to browse to your 2 level deep
category in two different ways as the example below would demonstrate
it.

say, your category has a top level item "MULTIMEDIA" and a child under
it called VIDEO.

Visually, we are talking about a situation like this;

Category taxonomy

multimedia
    video
    audio
topics
    science
    politics
Well, you may get to that child (video) in the following 2 different ways;

yoursite.com/category/multimedia/video or yoursite.com/category/video

The point here is that WP brings you to the exact same page,
regardless of which URL has been used, and there are no redirects here
neither, so both URL's remain on the visitor's browser as is just like
it was requested at the first place. And with either URL, the
resulting content is identical.

That's a hateful situation by Google.

Google punishes such sites cause your web site got the same exact
content appearing under 2 different URL's. ( This is of course when
you happen to use both URLs. ) Sure, Nobody would want to do that
deliberarely but sometimes you end up with that. And this question is
all about that case.

Let's say, you wanted to pick the simpler URL for your VIDEO category
and you want to stick to that only. Basically, you want the URL to be

yoursite.com/category/video

This is easy to achieve when you use the custom menu feature that
comes with WordPress where you can specify a URL for that particular
custom menu item of yours. So, when visitors click on the VIDEO link
on the custom menu, they end up coming to

yoursite.com/category/video

No problems so far...

But as soon as they pick a post out of that category, and they end up
coming to a post where the post's meta data displays things like
"CATEGORIZED in" or "TAGGED by" etc, they will be exposed to the
alternative URL for that VIDEO category.

So, if a user clicks on the VIDEO link in the "Categorized in" area,
the URL that they will end up with would be

yoursite.com/category/multimedia/video

And with that, there goes your SEO ranking.

My question is what techniques do you use here so WordPress always and
always use one single URL, the URL you defined in the custom menu.

I thought, category slugs could do this, but when I checked it, slug
feature allows me to change only the category term in the URL, not the
path to it.

If it were to give me a choice like

video slug: /category/video

I would be done.

But that choice is not available at this moment. When you do that, you
end up with the following slug instead

categoryvideo

That's because / is not a valid character for a slug.

Please suggest an alternative way to tell WordPress to stick to
/category/video at all times.

Before suggesting the obvious, ( well, just skip the 'multimedia' and
make the 'video' a top level cat. ), let me say that that suggestion
won't work for our situation.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers 


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: category URL's and SEO ranking

Shasta Willson-2
I sometimes create a category page which displays any posts in the
category (but NOT posts in the children), and then links to the
children categories.  So far as I can tell this removes any path to
get to the subcategory posts from the parent category.

e.g. http://pprc.org/testing123/testbed/index.php/category/networking/

(After this goes live the testing parts of the URL will go away.)

You can use http://codex.wordpress.org/Template_Tags/in_category for
testing if the post is actually in THIS category (not a subcategory)
to decide whether to post it.  (Note if the client checks the parent
category then it's in it too.)

<?php
$cat_id = get_query_var('cat');
$catlist = get_categories('child_of=' . $cat_id);

 if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if (in_category($cat_id)) : ?>
        <div class="one_synopsis">
        <div class="cat_headline">
        <h1 class="storytitle"><a href="<?php echo get_permalink(); ?>"><?php
the_title(); ?></a></h1>
        <?php if (is_category('Blog')) : ?>
       <b><i><?php echo get_the_date( $d ); ?></b></i>
        <?php endif; ?>
        </div>
        <div class="storycontent">
                <?php the_advanced_excerpt('length=50&use_words=1&no_custom=0&exclude_tags=img,p,strong,h1,h2,h3,a,i,b,
em'); ?>
        </div>
        <div class="storyimage">
        <?php if( has_post_thumbnail() )
                        { the_post_thumbnail('carousel_thumbnail'); } ?>
        </div>
        <div style="clear:both;"></div>
        </div>
    <?php endif; ?>
<?php endwhile; else: ?>
<p><?php _e('Page not found.'); ?></p>
<?php endif;  ?>

<?php if ($catlist) {
        foreach ($catlist as $category) {
        echo '<div class="subcategory"><h1>Related Topic: <a href="' .
get_category_link( $category->term_id ) . '" title="' . sprintf( __(
"View all posts in %s" ), $category->name ) . '" ' . '>' .
$category->name.'</a></h1> ';
    echo '<p>'. $category->description . '</p> </div>';
   
  }
 } ?>

- Shasta
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: category URL's and SEO ranking

Falgout@87
This post has NOT been accepted by the mailing list yet.
In reply to this post by Haluk Karamete
The ranking of your keywords in search results depends on various factors. If you have a new website then it is hard to achieve high rankings that can cause delay in the sales. So you can also use Google and Facebook Ads Services along with SEO. These ad services are best to generate leads in less time.
Loading...