warsztatweb/yii2-seo-helper

从每个模型中设置SEO变量(标题、描述等);

dev-master 2017-09-07 08:51 UTC

This package is not auto-updated.

Last update: 2024-09-27 22:56:46 UTC


README

从每个模型中设置SEO变量(标题、描述等);

安装

安装此扩展的首选方式是通过 composer

运行以下命令

php composer.phar require --prefer-dist warsztatweb/yii2-seo-helper "*"

或者在您的 composer.json 文件的 require 部分添加

"warsztatweb/yii2-seo-helper": "*"

to

使用方法

一旦安装了扩展,只需在您的代码中使用它即可

在配置文件中附加组件

'components' => [
    'seo' => [
        'class' => 'warsztatweb\seo\Helper',
    ],
],

使用

设置SEO数据

echo Yii::$app->seo->set($model);

$model 应该具有以下属性才能正常工作

meta_title meta_description meta_keywords h1 params[] 例如:params["og:image"]

模块可以处理其他列,例如title、name、nazwa、tytul、tyt用于meta_title;例如lead、description、desc、html用于meta_description。它寻找名为baner、banner、thumb、image的列以自动生成og:image属性。

og标签基于meta_title和meta_desription自动生成

基于路由的SEO Meta

//todo

SEO重定向

要启用SEO重定向,请将其添加到配置文件中

'errorHandler' => [
    'class' => 'warsztatweb\seo\Redirect',
],

基于Amirax的SEO Tools for Yii 2 https://github.com/Amirax/yii2-seo-tools