Skip to content

pbCanonical

Сниппет для вывода мета тегов canonical

Parameters

ParameterDefaultDescription
contextswebList of contexts, separated by commas
defaultCanonicalfalseAdds a tag. If true — the canonical URL always points to the default context. If false — context is included.
defaultAlternatetrueAdds tags for other contexts. If false — skips the current context and/or default context alternates.

If the system setting pageblocks_context_aware is enabled, the contexts parameter will be ignored.

Examples

Page alias: page, domain: https://site.com, defaultCanonical = false

php
{'!pbCanonical'|snippet}
html
<link rel="canonical" href="https://site.com/page" />
<link rel="alternate" hreflang="en" href="https://site.com/en/page" />
html
<link rel="canonical" href="https://site.com/en/page" />
<link rel="alternate" hreflang="ru" href="https://site.com/page" />

Page alias: page, domain: https://site.com, defaultCanonical = true

php
{'!pbCanonical'|snippet: [
    'defaultCanonical' => true
]}
html
<link rel="canonical" href="https://site.com/page" />
<link rel="alternate" hreflang="en" href="https://site.com/en/page" />
html
<link rel="canonical" href="https://site.com/page" />
<link rel="alternate" hreflang="ru" href="https://site.com/page" />
<link rel="alternate" hreflang="en" href="https://site.com/en/page" />

© PageBlocks 2019-present