yeesoft / yii2-yee-seo
Yee CMS SEO 模块
0.1.0
2017-03-01 11:23 UTC
Requires
- yeesoft/yii2-yee-core: ~0.1.0
This package is auto-updated.
Last update: 2022-03-29 00:26:34 UTC
README
##Yee CMS - 搜索引擎优化模块
####后端模块用于管理翻译
本模块是 Yee CMS(基于 Yii2 框架)的一部分。
SEO 模块允许您轻松创建和管理网站上的搜索引擎优化记录。此模块还有助于您轻松生成 sitemap.xml 文件。
安装
- 运行以下命令之一:
composer require --prefer-dist yeesoft/yii2-yee-seo "~0.1.0"
或者
"yeesoft/yii2-yee-seo": "~0.1.0"
将以下内容添加到您的 composer.json
文件的 require 部分。
- 运行迁移
yii migrate --migrationPath=@vendor/yeesoft/yii2-yee-seo/migrations/
配置
- 在您的后端配置文件中
'modules' => [ 'seo' => [ 'class' => 'yeesoft\page\SeoModule', ], ],
- 在您的前端配置文件中
'components' => [ 'seo' => [ 'class' => 'yeesoft\seo\components\Seo', ], ],
网站地图配置
注意!对于多语言网站,将为所有语言生成链接。
- 在您的前端配置文件中
'components' => [ 'sitemap' => [ 'class' => 'yeesoft\seo\components\Sitemap', 'links' => [//list of links ['loc' => ['/site/index'], 'priority' => '1'], ['loc' => ['/blog/index']], ], 'models' => [//list of links generated using models [ 'items' => function () { return yeesoft\post\models\Post::find()->where(['status' => 1])->all(); }, 'loc' => function ($model) { return ['/site/index', 'slug' => $model->slug]; }, 'lastmod' => function ($model) { return $model->updated_at; }, ], ], ], ],
- 将操作添加到 SiteController(或另一个控制器)
public function actions() { return [ 'sitemap' => [ 'class' => 'yeesoft\seo\actions\SitemapAction', ], ]; }
- 为网站地图添加前端路由
'components' => [ 'urlManager' => [ ... 'rules' => [ ... 'sitemap.xml' => 'site/sitemap', ], ], ],