2

does adding the rel="next" tag after the page is loaded with a small javascript still useful for SEO and google?
i have a problem in my code, basically the total number of pages in the catalog is calculated near the end of the code. the only way i could check that i'm in the last page is first to load everything else, but at that point i wouldn't be able anymore to write in the header with php. how can i solve this?
i thought about a javascript that writes in the header at the end if it is not the last page, OR a javascript that removes the same thing if it is the last page, but i don't know if this would work for google....

  • are you running one of those kind of sites where part of the page shows and as you scroll more, then more of the page starts loading after? – Mike Apr 28 '15 at 3:51
  • No, its just a normal catalog page. Only that the catalog list is generated every time in php(like search queries, different categories-subcategories ect). So the only moment I know how long the catalog is its when I generate it. That's in body section and not in header anymore – euge9522 Apr 28 '15 at 6:57
1

You could use Javascript to modify the head, but as search engines don't generally run Javascript that wouldn't work. What you probably want to do is PHP output buffering as described in the accepted answer to this question. By the time you get to the end of the page you know what needs to go in the head. Then you can output the head and release everything stored in the buffer.

I've never used output buffering myself, but it looks like it does what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.