S
S
Sergey2016-03-31 15:09:48
MODX
Sergey, 2016-03-31 15:09:48

How to set rel=canonical on modx evo?

Good day!
There is a site on ModX Evo, where pagination of the form
site.ru/category_name/?page=2 is used for catalog sections.
I found the snippet:

<?php
return $modx->documentIdentifier == $modx->config['site_start'] ? '<link rel="canonical" href="[(site_url)]" />' : '<link rel="canonical" href="[(site_url)][~[*id*]~]" />';
?>

The problem is that rel=canonical is shown on all pages, but it should only be on non-canonical pages with pagination. What needs to be improved in the snippet?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zooks, 2016-03-31
@zooks

If all pages show the correct rel="canonical", then there is nothing wrong with that.
Instead of a snippet, you can simply paste this code into the head of the inner page template:

<link rel="canonical" href="[(site_url)][~[*id*]~]" />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question