mislav/will_paginate

Page 1 without page param

AnubixXx opened this issue · 2 comments

Hi,

is there possibility to change ?page=1 param in will_paginate helper? I explain it, i have the url:
www.mywebsite.com/t-shirts
and pagination is
www.mywebsite.com/t-shirts?page=1
www.mywebsite.com/t-shirts?page=2
www.mywebsite.com/t-shirts?page=3

But page=1 is same as www.mywebsite.com/t-shirts. So there is duplicity because of SEO. In menu I just link to www.mywebsite.com/t-shirts, but pagination helper will_paginate is still redering link to page=1. Is there a way to change to remove page=1 param without routing?

Thanks.

Closing in favor of the linked solution. In short: you can't avoid ?page=1, but you can subclass LinkRenderer and override the URL generation logic in any way you please

def url(page)
@base_url_params ||= begin
url_params = merge_get_params(default_url_params)
url_params[:only_path] = true
merge_optional_params(url_params)
end
url_params = @base_url_params.dup
add_current_page_param(url_params, page)
@template.url_for(url_params)
end