tomk79 / px2-seo-utils
为 Pickles 2 添加 SEO 相关实用工具。
0.1.0
2021-08-15 12:36 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpdocumentor/phpdocumentor: ^2.7.0
- phpunit/phpunit: ^4.1.0
- pickles2/px-fw-2.x: ~2.1||~2.0
- pickles2/px2-multitheme: ~2
- pickles2/px2-path-resolver: ~2
- pickles2/px2-px2dthelper: ~2
- pickles2/px2-remove-attr: ~2
- pickles2/px2-sitemapexcel: ~2
This package is auto-updated.
Last update: 2024-09-15 19:11:24 UTC
README
为 Pickles 2 添加 SEO 相关实用工具。
设置 - Setup
1. 安装 - Installation
在设置好 Pickles 2 后,执行以下命令。
$ composer require tomk79/px2-seo-utils;
2. 在 $conf->funcs->before_sitemap
中设置
编辑设置文件 config.php
(通常为 ./px-files/config.php
),并按以下方式追加。请确保在主题之后执行。
$conf->funcs->before_sitemap = array( // 〜中略〜 // SEO Utils tomk79\pickles2\px2_seo_utils\config::init(array( /* プラグインの設定 (後述) */ )), // 〜中略〜 );
使用方法 - Usage
robots 标签的输出
插件设置
将 robots->enable
设置为 true
。
// SEO Utils tomk79\pickles2\px2_seo_utils\config::init(array( 'robots' => array( // metaタグ robots の自動挿入を有効にします。 'enable' => true, ), )),
扩展网站地图
向网站地图添加以下列。
robots:follow
robots:index
robots:archive
在添加到网站地图的扩展列中,输入每个页面的设置。
- 输入
on
、yes
、true
、1
等表示肯定命令(例如:follow
)。 - 输入
off
、no
、false
、0
等表示否定命令(例如:nofollow
)。 - 输入空白、未定义的列或
null
时,则不会输出。
如果有三个项目中的任何一个被设置,则会在 head
元素的关闭标签前输出类似于 <meta name="robots" content="follow,noindex" />
的代码。
直接获取 meta 标签
如果需要直接获取标签,可以通过 $seoUtils->robots()->tag()
方法获取,此时还会发出 X-Robots-Tag
标题。
<html> <head> <?php $seoUtils = new \tomk79\pickles2\px2_seo_utils\main($px); $tag = $seoUtils->robots()->tag(array( 'follow'=>'no', 'index'=>'', 'archive'=>'', )); echo $tag; ?> </head> </html>
生成 sitemap.xml
插件设置
将 sitemapXml->enable
设置为 true
。
// SEO Utils tomk79\pickles2\px2_seo_utils\config::init(array( 'sitemapXml' => array( // sitemap.xml の自動生成機能を有効にします。 'enable' => true, // ここに設定したパスへのリクエストをトリガーに、sitemap.xml が生成されます。 'trigger' => '/index.html', // 生成した sitemap.xml の保存先のパスです。 // `.px_execute.php` が置かれているディレクトリをルートとして設定します。 'dist' => '/sitemap.xml', ), )),
变更日志 - Change log
tomk79/px2-seo-utils v0.1.0 (2021年8月15日)
- 首次发布。
许可证 - License
MIT 许可证
作者 - Author
- Tomoya Koyanagi tomk79@gmail.com
- 网站: https://www.pxt.jp/
- Twitter: @tomk79 https://twitter.com/tomk79/