Changing rel='next' and rel='prev' href values with ajax pagination for SEO benefits

StackOverflow https://stackoverflow.com/questions/22719637

  •  23-06-2023
  •  | 
  •  

Вопрос

I have a page which has ajax based pagination built into it. The pagination is for a 'reviews' feature in the page. According to Google's webmaster blog, having rel="next" and rel="prev" values are beneficial for SEO.

I added the following tags to the head:

<link id="PrevHeadLink" rel="prev", href="someurl?page=1"></link>
<link id="NextHeadLink" rel="next", href="someurl?page=3"></link>

I have a client side script that runs when the pagination is successful:

function AjaxPaginationSuccess(newNextValue, newPrevValue) {
  $('#NextHeadLink').attr('href', newNextValue);
  $('#PrevHeadLink').attr('href', newPrevValue);
  /*Do other stuff*/
}

After I click to go to a different page, when I check the source using Chrome Developer tools, the change is reflected in the href values of the links. But if I just do a regular view page source, the change does not get reflected in the href values and the links seem to have the same old values they had prior to the page change event. Can a search bot detect these changes?

Additional Information: Not sure if this information helps but I have used history.pushState to try and achieve SEO friendly AJAX pagination. My site runs on a NodeJs, CoffeeScript, and Jade stack. I use jQuery for client side scripting. I don't have the same problem that I'm facing with the rel links for the rest of the paged content because I load a new Jade template into the pagination div when the Ajax request is successful. Something like this:

success: function(html) {
        $('#PaginationModule').html(html);
        AjaxPaginationSuccess(newNextValue, newPrevValue);
      }

Thanks! Please let me know if I can provide you with any additional information information to help tackle this problem.

Это было полезно?

Решение

I don't know if search bots would support html5 functionalities like pushState, especially when most of the time, they have don't execute javascript.

If you can load each page with the url someurl?page=[PageId] and the prev and next links are redirecting to someurl?page=[PageId-1] and someurl?page=[PageId+1], you should be ok.

Other thing, your pagination links should have the href attribute redirecting tosomeurl?page=[CorrespondingPageId] in case the browser doesn't support ajax or html5.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top