Skip to content

Commit

Permalink
Register meta tags Description, Keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
akiraz2 committed Apr 10, 2018
1 parent 0c94913 commit 5b84fae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
21 changes: 19 additions & 2 deletions views/frontend/default/index.php
Expand Up @@ -6,8 +6,25 @@
*/

use yii\widgets\ListView;
use \akiraz2\blog\Module;

//$this->title = Yii::$app->params['blogTitle'] . ' - ' . Yii::$app->params['blogTitleSeo'];
$this->title = Module::t('blog', 'Blog');
Yii::$app->view->registerMetaTag([
'name' => 'description',
'content' => Yii::$app->name. ' '.Module::t('blog', 'Blog')
]);
Yii::$app->view->registerMetaTag([
'name' => 'keywords',
'content' => Yii::$app->name.', '.Module::t('blog', 'Blog')
]);

if(Yii::$app->get('opengraph', false)) {
Yii::$app->opengraph->set([
'title' => $this->title,
'description' => Module::t('blog', 'Blog'),
//'image' => '',
]);
}
//$this->params['breadcrumbs'][] = '文章';

/*$this->breadcrumbs=[
Expand All @@ -21,7 +38,7 @@
<div class="container">
<div class="row">
<div class="col-md-7">
<h1 class="title title--1"><?= \akiraz2\blog\Module::t('blog', 'Blog'); ?></h1>
<h1 class="title title--1"><?= Module::t('blog', 'Blog'); ?></h1>
</div>
<div class="col-md-5">
<div class="blog-index__search">
Expand Down
9 changes: 9 additions & 0 deletions views/frontend/default/view.php
Expand Up @@ -11,6 +11,15 @@
use yii\helpers\Html;

$this->title = $post->title;
Yii::$app->view->registerMetaTag([
'name' => 'description',
'content' => $post->brief
]);
Yii::$app->view->registerMetaTag([
'name' => 'keywords',
'content' => $this->title
]);

if(Yii::$app->get('opengraph', false)) {
Yii::$app->opengraph->set([
'title' => $this->title,
Expand Down

0 comments on commit 5b84fae

Please sign in to comment.