Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
511 views
in Q2A Core by

Pagination logic is not correct. It depends on "start" GET parameter, which affects the offset.

But if I change the number of questions displayed, it causes some SEO problems.

You may say that all I need to do is to close pagination from indexing... But this is a holywar topic for another discussion.

For example, in my case, I've changed number of questions per page from 20 to 30 and this caused pages such as:

  • /?start=20
  • /?start=30

have similar titles, which are "[category name] - page 2".

Or:

  • /?start=320
  • /?start=330

Have title "[category name] - page 17".

This creates duplicate titles which is really bad for SEO.

Moreover I can put ANY number in start parameter and Q2A will give me a 200 OK answer with some content. Search engines just don't know, that pages like /?start=115 or /?start=333 exist. But if they do - it will create even more duplicate pages.

The correct approach

The right, or best practice to organize pagination is to use PAGE NUMBER instead of OFFSET (start in our case).

Current logic: use "start" parameter as offset. Take in count the number of questions from site options. But depending on number of questions displayed, start parameter will always change!

Correct logic: use page number which will consider number of questions displayed from site options and page number will always remain the same.

So for 30 questions per page, instead of /?start=30 for second page we must have /?page=2 and page=2 parameter has to stay constant (!!!), not depending on number of questions per page option.

If number of questions changes to, lets say 50, pager links will not change to /?start=50 for second page, it will remain as /?page=2 and will not break our SEO.

This is implemented in all major CMS's. I wonder why Q2A had to go the other way.

I've looked into the code. All logic divides into two parts:

  1. creating links for pager;
  2. creating offset for correct database queries for each page.

This is described in following files:

  1. \qa-include\app\format.php lines 1212 - 1282 function qa_html_page_links()
  2. \qa-include\app\q-list.php lines 29 - 151 function qa_q_list_page_content()
  3. \qa-include\app\search.php lines 29 - 140 function qa_get_search_results()
  4. and maybe in some other places...

Sounds not very hard to override this.

Who wants to cooperate and write a plugin? Or maybe this issue will be corrected in future releases of Q2A?

Q2A version: 1.8.3

Please log in or register to answer this question.

...