Commit ea76386585cf38f04f277aa9db38081393dab9a5
1 parent
bc3d1ced
seo hreflang and sitemap
Showing
8 changed files
with
157 additions
and
12 deletions
Show diff stats
backend/config/main.php
| @@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
| 2 | use artbox\core\components\SeoUrlManager; | 2 | use artbox\core\components\SeoUrlManager; |
| 3 | use artbox\core\models\Page; | 3 | use artbox\core\models\Page; |
| 4 | use common\components\Sitemap; | 4 | use common\components\Sitemap; |
| 5 | + use artbox\weblog\models\Article; | ||
| 6 | + use common\models\Objectkb; | ||
| 5 | 7 | ||
| 6 | $params = array_merge( | 8 | $params = array_merge( |
| 7 | require( __DIR__ . '/../../common/config/params.php' ), | 9 | require( __DIR__ . '/../../common/config/params.php' ), |
| @@ -94,15 +96,38 @@ | @@ -94,15 +96,38 @@ | ||
| 94 | ], | 96 | ], |
| 95 | 'urlManagerFrontend' => [ | 97 | 'urlManagerFrontend' => [ |
| 96 | 'class' => SeoUrlManager::className(), | 98 | 'class' => SeoUrlManager::className(), |
| 97 | - 'baseUrl' => '/', | ||
| 98 | 'enablePrettyUrl' => true, | 99 | 'enablePrettyUrl' => true, |
| 99 | 'showScriptName' => false, | 100 | 'showScriptName' => false, |
| 100 | - 'rules' => [], | 101 | + // 'dontShowDefaulPrefix' => true, |
| 102 | + 'rules' => [ | ||
| 103 | + '\/robots.txt' => 'site/robots', | ||
| 104 | + ], | ||
| 105 | + 'processRoutes' => [ | ||
| 106 | + 'object/view', | ||
| 107 | + 'blog/article', | ||
| 108 | + 'blog/tag', | ||
| 109 | + 'blog/category', | ||
| 110 | + 'page/view', | ||
| 111 | + ], | ||
| 101 | ], | 112 | ], |
| 102 | 'sitemap' => [ | 113 | 'sitemap' => [ |
| 103 | 'class' => Sitemap::className(), | 114 | 'class' => Sitemap::className(), |
| 104 | 'entities' => [ | 115 | 'entities' => [ |
| 105 | [ | 116 | [ |
| 117 | + 'class' => Objectkb::className(), | ||
| 118 | + 'conditions' => [ | ||
| 119 | + [ 'status' => 1 ], | ||
| 120 | + ], | ||
| 121 | + 'url' => 'object/view', | ||
| 122 | + ], | ||
| 123 | + [ | ||
| 124 | + 'class' => Article::className(), | ||
| 125 | + 'conditions' => [ | ||
| 126 | + [ 'status' => 1 ], | ||
| 127 | + ], | ||
| 128 | + 'url' => 'blog/article', | ||
| 129 | + ], | ||
| 130 | + [ | ||
| 106 | 'class' => Page::className(), | 131 | 'class' => Page::className(), |
| 107 | 'conditions' => [ | 132 | 'conditions' => [ |
| 108 | [ 'in_menu' => 1 ], | 133 | [ 'in_menu' => 1 ], |
common/components/Sitemap.php
| @@ -131,6 +131,7 @@ | @@ -131,6 +131,7 @@ | ||
| 131 | $urlManager->createAbsoluteUrl( | 131 | $urlManager->createAbsoluteUrl( |
| 132 | [ | 132 | [ |
| 133 | $entity[ 'url' ], | 133 | $entity[ 'url' ], |
| 134 | + 'alias' => $record->lang->alias, | ||
| 134 | 'id' => $record->getAttribute('id'), | 135 | 'id' => $record->getAttribute('id'), |
| 135 | ] | 136 | ] |
| 136 | ) | 137 | ) |
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | - return [ | ||
| 4 | 2 | ||
| 5 | - ]; | ||
| 6 | \ No newline at end of file | 3 | \ No newline at end of file |
| 4 | +return [ | ||
| 5 | + 1 => [ | ||
| 6 | + 'entity' => 'common\\models\\Objectkb', | ||
| 7 | + 'status' => '1', | ||
| 8 | + 'frequency' => 'daily', | ||
| 9 | + 'priority' => '0.9', | ||
| 10 | + 'id' => 1, | ||
| 11 | + ], | ||
| 12 | + 2 => [ | ||
| 13 | + 'entity' => 'artbox\\weblog\\models\\Article', | ||
| 14 | + 'status' => '1', | ||
| 15 | + 'frequency' => 'weekly', | ||
| 16 | + 'priority' => '0.8', | ||
| 17 | + 'id' => 2, | ||
| 18 | + ], | ||
| 19 | + 3 => [ | ||
| 20 | + 'entity' => 'artbox\\core\\models\\Page', | ||
| 21 | + 'status' => '1', | ||
| 22 | + 'frequency' => 'weekly', | ||
| 23 | + 'priority' => '0.6', | ||
| 24 | + 'id' => 3, | ||
| 25 | + ], | ||
| 26 | +]; | ||
| 7 | \ No newline at end of file | 27 | \ No newline at end of file |
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | - return [ | ||
| 4 | 2 | ||
| 5 | - ]; | ||
| 6 | \ No newline at end of file | 3 | \ No newline at end of file |
| 4 | +return [ | ||
| 5 | + 1 => [ | ||
| 6 | + 'url' => 'http://www.new-kbenergy.test', | ||
| 7 | + 'frequency' => 'always', | ||
| 8 | + 'priority' => '1', | ||
| 9 | + 'id' => 1, | ||
| 10 | + ], | ||
| 11 | + 2 => [ | ||
| 12 | + 'url' => 'http://www.new-kbenergy.test/ru/site/legal', | ||
| 13 | + 'frequency' => 'daily', | ||
| 14 | + 'priority' => '0.9', | ||
| 15 | + 'id' => 2, | ||
| 16 | + ], | ||
| 17 | + 3 => [ | ||
| 18 | + 'url' => 'http://www.new-kbenergy.test/ru/site/individual', | ||
| 19 | + 'frequency' => 'daily', | ||
| 20 | + 'priority' => '0.9', | ||
| 21 | + 'id' => 3, | ||
| 22 | + ], | ||
| 23 | +]; | ||
| 7 | \ No newline at end of file | 24 | \ No newline at end of file |
frontend/views/layouts/main.php
| @@ -23,6 +23,7 @@ | @@ -23,6 +23,7 @@ | ||
| 23 | use yii\web\View; | 23 | use yii\web\View; |
| 24 | use yii\widgets\Breadcrumbs; | 24 | use yii\widgets\Breadcrumbs; |
| 25 | use common\models\Feedback; | 25 | use common\models\Feedback; |
| 26 | + use frontend\widgets\HreflangWidget; | ||
| 26 | 27 | ||
| 27 | AppAsset::register($this); | 28 | AppAsset::register($this); |
| 28 | $user = \Yii::$app->user->identity; | 29 | $user = \Yii::$app->user->identity; |
| @@ -71,6 +72,9 @@ | @@ -71,6 +72,9 @@ | ||
| 71 | <meta charset="<?= \Yii::$app->charset ?>"> | 72 | <meta charset="<?= \Yii::$app->charset ?>"> |
| 72 | <meta name="viewport" content="width=device-width, initial-scale=1"> | 73 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 73 | <?= Html::csrfMetaTags() ?> | 74 | <?= Html::csrfMetaTags() ?> |
| 75 | + | ||
| 76 | + <?= HreflangWidget::widget()?> | ||
| 77 | + | ||
| 74 | <title><?= Html::encode($seo->title) ?></title> | 78 | <title><?= Html::encode($seo->title) ?></title> |
| 75 | <?php $this->head() ?> | 79 | <?php $this->head() ?> |
| 76 | </head> | 80 | </head> |
frontend/views/site/index.php
| @@ -409,13 +409,21 @@ JS; | @@ -409,13 +409,21 @@ JS; | ||
| 409 | <iframe width="100%" height="100%" src="https://www.youtube.com/embed/NCNqrRzXpTw" frameborder="0" allowfullscreen=""></iframe> | 409 | <iframe width="100%" height="100%" src="https://www.youtube.com/embed/NCNqrRzXpTw" frameborder="0" allowfullscreen=""></iframe> |
| 410 | </div> | 410 | </div> |
| 411 | <div class="post" style="background-image: url('/img/post_cover_2.jpg');"> | 411 | <div class="post" style="background-image: url('/img/post_cover_2.jpg');"> |
| 412 | - <a href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti" target="_blank"> | 412 | + <a |
| 413 | + rel="nofollow" | ||
| 414 | + href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti" | ||
| 415 | + target="_blank" | ||
| 416 | + > | ||
| 413 | <div class="title"><?=\Yii::t('app', 'index_medias3')?></div> | 417 | <div class="title"><?=\Yii::t('app', 'index_medias3')?></div> |
| 414 | <div class="blue_arrow"></div> | 418 | <div class="blue_arrow"></div> |
| 415 | </a> | 419 | </a> |
| 416 | </div> | 420 | </div> |
| 417 | <div class="post" style="background-image: url('/img/post_cover_3.jpg');"> | 421 | <div class="post" style="background-image: url('/img/post_cover_3.jpg');"> |
| 418 | - <a href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html" target="_blank"> | 422 | + <a |
| 423 | + rel="nofollow" | ||
| 424 | + href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html" | ||
| 425 | + target="_blank" | ||
| 426 | + > | ||
| 419 | <div class="title"><?=\Yii::t('app', 'index_medias4')?></div> | 427 | <div class="title"><?=\Yii::t('app', 'index_medias4')?></div> |
| 420 | <div class="blue_arrow"></div> | 428 | <div class="blue_arrow"></div> |
| 421 | </a> | 429 | </a> |
frontend/views/site/media-about.php
| @@ -31,7 +31,11 @@ use yii\web\View; | @@ -31,7 +31,11 @@ use yii\web\View; | ||
| 31 | <div class="col-sm-4"> | 31 | <div class="col-sm-4"> |
| 32 | <div class="box-image"> | 32 | <div class="box-image"> |
| 33 | <div class="post" style="background-image: url('/img/post_cover_3.jpg');"> | 33 | <div class="post" style="background-image: url('/img/post_cover_3.jpg');"> |
| 34 | - <a href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html" target="_blank"> | 34 | + <a |
| 35 | + rel="nofollow" | ||
| 36 | + href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html" | ||
| 37 | + target="_blank" | ||
| 38 | + > | ||
| 35 | <div class="title"><?= \Yii::t('app', 'media_text2') ?></div> | 39 | <div class="title"><?= \Yii::t('app', 'media_text2') ?></div> |
| 36 | </a> | 40 | </a> |
| 37 | </div> | 41 | </div> |
| @@ -40,7 +44,11 @@ use yii\web\View; | @@ -40,7 +44,11 @@ use yii\web\View; | ||
| 40 | <div class="col-sm-4"> | 44 | <div class="col-sm-4"> |
| 41 | <div class="box-image"> | 45 | <div class="box-image"> |
| 42 | <div class="post" style="background-image: url('/img/post_cover_2.jpg');"> | 46 | <div class="post" style="background-image: url('/img/post_cover_2.jpg');"> |
| 43 | - <a href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti" target="_blank"> | 47 | + <a |
| 48 | + rel="nofollow" | ||
| 49 | + href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti" | ||
| 50 | + target="_blank" | ||
| 51 | + > | ||
| 44 | <div class="title"><?= \Yii::t('app', 'media_text3') ?></div> | 52 | <div class="title"><?= \Yii::t('app', 'media_text3') ?></div> |
| 45 | </a> | 53 | </a> |
| 46 | </div> | 54 | </div> |
| 1 | +<?php | ||
| 2 | + namespace frontend\widgets; | ||
| 3 | + | ||
| 4 | + /** | ||
| 5 | + * User: timur | ||
| 6 | + * Date: 17.02.18 | ||
| 7 | + * Time: 8:29 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | + use yii\base\Widget; | ||
| 11 | + use artbox\core\models\Language; | ||
| 12 | + use yii\helpers\Url; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * Class HreflangWidget | ||
| 16 | + * | ||
| 17 | + * @property Language[] $languages | ||
| 18 | + * | ||
| 19 | + * @package frontend\widgets | ||
| 20 | + */ | ||
| 21 | + class HreflangWidget extends Widget | ||
| 22 | + { | ||
| 23 | + | ||
| 24 | + public $languages; | ||
| 25 | + | ||
| 26 | + public function init() | ||
| 27 | + { | ||
| 28 | + parent::init(); | ||
| 29 | + | ||
| 30 | + if(!isset($this->languages)){ | ||
| 31 | + $this->languages = Language::getActive(); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public function run() | ||
| 37 | + { | ||
| 38 | + | ||
| 39 | + foreach ($this->languages as $language){ | ||
| 40 | + | ||
| 41 | + ?> | ||
| 42 | + | ||
| 43 | + <link | ||
| 44 | + rel="alternate" | ||
| 45 | + hreflang="<?=$language->url?>" | ||
| 46 | + href="<?=Url::to( | ||
| 47 | + [ \Yii::$app->requestedRoute ] + | ||
| 48 | + \Yii::$app->request->get() + | ||
| 49 | + [ 'language_id' => $language->id ], | ||
| 50 | + | ||
| 51 | + true | ||
| 52 | + )?>" | ||
| 53 | + > | ||
| 54 | + | ||
| 55 | + <?php | ||
| 56 | + | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + parent::run(); | ||
| 61 | + } | ||
| 62 | + } | ||
| 0 | \ No newline at end of file | 63 | \ No newline at end of file |