Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO optimize pagination with rel="prev" & rel="next" #183

Closed
Rio517 opened this issue Sep 15, 2011 · 26 comments
Closed

SEO optimize pagination with rel="prev" & rel="next" #183

Rio517 opened this issue Sep 15, 2011 · 26 comments
Labels

Comments

@Rio517
Copy link

Rio517 commented Sep 15, 2011

I wanted to propose that will_paginate include a view helper for SEO optimization, per a recent official Google blog post

<link rel="prev" href="http://www.example.com/article?story=abc&page=1&sessionid=123" />
<link rel="next" href="http://www.example.com/article?story=abc&page=3&sessionid=123" />

link: http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html

Thanks!

@mislav
Copy link
Owner

mislav commented Sep 15, 2011

Hey! That would be valid use if we didn't have actual hyperlinks with rel="prev/next", which we have for a long time now each time you generate pagination with will_paginate().

Per HTML5 spec, these rel values are a good enough hint to the user agent that these point to the resources that represent previous/next pages of results. We shouldn't need additional <link> elements in the <head>.

@mislav mislav closed this as completed Sep 15, 2011
@RustyDev
Copy link

If I were to do this how would it be implemented?

@RustyDev
Copy link

"Google indexing of paginated content, rel="next" and rel="prev" declarations belong in the <head> section, not in the body as anchor links."

http://www.google.com/support/forum/p/Webmasters/thread?tid=344378292ff91e8d&hl=en

@forest
Copy link

forest commented May 10, 2012

You would think that rel next/prev on the actual links would be good enough, but not so according to Google.
http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html

Here is an example from kaminari.
https://github.com/amatsuda/kaminari/pull/200/files

@tganzarolli
Copy link

That feature would be very much appreciated. As others stated here, google only considers relevant the rel attributes inside a link tag, not in an 'a' tag. I am going to do a dirty patch for my project. If things turn out well, I can make a pull request.

@csgavino
Copy link

csgavino commented Jun 6, 2013

Bump, has this ever been solved?

@mislav
Copy link
Owner

mislav commented Jun 6, 2013

Not that I know of. The solution would require a separate will_paginate helper method to generate the <link> tags, as well as a method to inject those in the current page's <head>. This is not straightforward to do in Rails, and would require changes to your app's layout(s).

@Fernan2
Copy link

Fernan2 commented Jul 15, 2013

Our SEO has just asked us for this; and although Kaminari already supports, Kaminari lacks of anchoring support, which is very useful for us... I will also appreciate this, but in the meantime, I'll ask @tganzarolli for his dirty patch.

@mislav
Copy link
Owner

mislav commented Jul 15, 2013

Alright, gonna reopen this and anyone is welcome to take a stab at the implementation.

@mislav mislav reopened this Jul 15, 2013
@lloydmeta
Copy link

Pretty much straight port of Kaminari's method in my pull request #324

@Fernan2
Copy link

Fernan2 commented Oct 7, 2013

It will be nice if you could merge @lloydmeta 's PR...

Thks!

@mindtonic
Copy link

Just checking in on the status of this pull request. Any chance of it being included?

@blakeman8192
Copy link

I would like this merged as well!

@binyamindavid
Copy link

👍

1 similar comment
@johnpash
Copy link

johnpash commented Feb 4, 2015

👍

@subimage
Copy link

subimage commented Apr 1, 2015

MISLAV WHY U NO MERGE :(

@scruti
Copy link

scruti commented Apr 1, 2015

🕦

@aleks
Copy link

aleks commented Aug 5, 2015

We are in need of this too! A merge would be kinda cool. 👍

@ryanahamilton
Copy link

👍

2 similar comments
@noafroboy
Copy link

👍

@alpemaca
Copy link

alpemaca commented Dec 1, 2015

👍

jonatack added a commit to jonatack/will_paginate that referenced this issue Dec 6, 2015
This is a port of PR mislav#324 by @lloydmeta in will_paginate:

mislav#324

in response to issue mislav#183:

'SEO optimize pagination with rel="prev" & rel="next"'

mislav#183
@jonatack
Copy link
Contributor

jonatack commented Dec 6, 2015

Thanks @lloydmeta for the PR. I merged it into my version of will_paginate for Ruby 2.2/Rails 5.

Folks, +1 comments aren't helpful. If you want this feature (or any other), just fork the gem and merge it in 😃

mpolakis pushed a commit to mpolakis/will_paginate that referenced this issue Mar 11, 2016
This is a port of PR mislav#324 by @lloydmeta in will_paginate:

mislav#324

in response to issue mislav#183:

'SEO optimize pagination with rel="prev" & rel="next"'

mislav#183
@mpolakis
Copy link

Thanks @lloydmeta and @jonatack for your work on this issue. Also, thanks @mislav for building this wonderful gem. Any idea if you actually intend to merge this? If yes, when? Thanks.

@dignoe
Copy link

dignoe commented Apr 21, 2016

I've made a gist on how to monkey patch will_paginate v3.0.7 to add rel="next" & rel="prev" links to your header. I only use this on pages that require custom link generation, so this also includes a patch to use a custom url generator if a specific option is passed.

https://gist.github.com/dignoe/0f76e81949b46e48e4ff4f992aa93aeb

@erpe
Copy link

erpe commented Sep 9, 2016

if you don't like monkey patching: a simple view-helper as a rails-railtie: https://github.com/erpe/rails_will_paginate_seo_helper

christemple pushed a commit to notonthehighstreet/will_paginate that referenced this issue Oct 6, 2016
This is a port of PR mislav#324 by @lloydmeta in will_paginate:

mislav#324

in response to issue mislav#183:

'SEO optimize pagination with rel="prev" & rel="next"'

mislav#183
snowblink pushed a commit to notonthehighstreet/will_paginate that referenced this issue Mar 1, 2019
This is a port of PR mislav#324 by @lloydmeta in will_paginate:

mislav#324

in response to issue mislav#183:

'SEO optimize pagination with rel="prev" & rel="next"'

mislav#183
@mislav
Copy link
Owner

mislav commented May 29, 2023

Decided not to go with this feature and forgot to close this. #324 (comment)

@mislav mislav closed this as completed May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests