Blog Pagination with rel=“next” and rel=“prev”

  • It seems that the blog extension in Pagekit does not offer a relationship between the component URLs of the pages (if you have multiple pages of your blog).
    Regarding to Google there are two solutions, having a "view-all" page or implementing rel=”next” and rel=”prev” links in the meta header for each page.

    I wrote a small script for the second resolving, that adds this meta-links, when there are more then 1 pages in the /blog/ overview site.

    It may not be the best solution, because some the core-code of pagekit has to be changed, but it does the job.

    - maybe somebody needs it.


    url: (page 1 of 3)

    header: <link rel="next" href="/blog/page/2">

    url: (page 2 of 3)

    header: <link rel="prev" href="/blog/page/1">

    <link rel="next" href="/blog/page/3">

    url: (page 3 of 3)

    header: <link rel="prev" href="/blog/page/2">

    this files has to be edited:

    • \pagekit\app\modules\view\src\Helper\StyleHelper.php ~ L: 62

    change to:

    now we can do something like: <?php $view->style('next', '/blog/page/2') ?> in our templates to write <link rel="next" href="/blog/page/2"> in the header of the page.

    • \<your-theme>\views\blog\posts.php ~ L: 45

    Info: You can copy the original posts.php and post.php from \pagekit\packages\pagekitblog\views\ to ...\<your-theme>\views\blog\ to modify them here.

    change to:

    here we are using the pagination function of the blog to insert the right link to the header.

  • SPQRInc

    Approved the thread.