Commit f41b22413adec62d562b1b96a7a98091d4d4844e
1 parent
d05fedfc
add canonical to category & blog pages
Showing
1 changed file
with
11 additions
and
0 deletions
Show diff stats
frontend/views/layouts/main.php
@@ -101,6 +101,17 @@ | @@ -101,6 +101,17 @@ | ||
101 | JS; | 101 | JS; |
102 | $this->registerJs($preloader, View::POS_READY); | 102 | $this->registerJs($preloader, View::POS_READY); |
103 | 103 | ||
104 | +if((Yii::$app->controller->id ==='category'||'blog')) { | ||
105 | + $canonicalUrl = Yii::$app->request->getHostInfo(). '/' . Yii::$app->request->getPathInfo(); | ||
106 | + $canonicalUrl = rtrim($canonicalUrl, '/index'); | ||
107 | + $this->registerLinkTag( | ||
108 | + [ | ||
109 | + 'href' => $canonicalUrl, | ||
110 | + 'rel' => 'canonical' | ||
111 | + ] | ||
112 | + ); | ||
113 | +} | ||
114 | + | ||
104 | ?> | 115 | ?> |
105 | 116 | ||
106 | <?php $this->beginPage() ?> | 117 | <?php $this->beginPage() ?> |