milankyncl/nette-seo
Composer 安装命令:
composer require milankyncl/nette-seo
包简介
Nette SEO module for building SEO optimized website.
README 文档
README
Nette-framework SEO extension is a simple module to build head meta tags for website in simple steps.
Installation
composer require milankyncl/nette-seo
Usage
-
Register extension in your
config.neonfile.extensions: # ... seo: MilanKyncl\Nette\SEO\DI\SEOExtension
-
Set your preferences.
seo: site_name: "Super cool website!" # Your website Name description: "Description for your website" # Website default description image: url: "//www.example.cz/super-cool-image.png" # Preview image URL width: 1260 # Image width height: 630 # Image height # Or just: # image: "//www.example.cz/super-cool-image.png" separator: '-' # Title separator customTags: # Your custom tags, will show before title tag copyright: 'Company 2018' # Copyright eg. author: 'Name <email@email.com>' # Author eg.
-
Inject SEOResolver factory and MetaTags component in your BasePresenter.
// With @inject annotation: /** @var \MilanKyncl\Nette\SEO\SEOResolver @inject */ public $seo; /** @var \MilanKyncl\Nette\SEO\Components\MetaTags @inject */ public $metaTagsComponent; // Or in constructor: public function __construct(\MilanKyncl\Nette\SEO\SEOResolver $seo, \MilanKyncl\Nette\SEO\Components\MetaTags $metaTagsComponent) { $this->seo = $seo; $this->metaTagsComponent = $metaTagsComponent; }
-
Create Seo Meta tags component (in BasePresenter) and in your action set title, description, or custom meta tags for your head. Use methods from documentation
// HomepagePresenter eg. public function indexAction() { $this->seo->setTitle('Homepage'); // The title will look like: Homepage - Super cool website! ({$title} {$separator} {$site_name}) } // Base Presenter public function createComponentSeoMetaTags() { // You can use some methods to change default options from documentation here // before returning the component // $this->seo–>setTitle($title) // $this->seo–>setDescription($description) // $this->seo–>setImage($url, $width, $height) // Use this right before returning the component $this->metaTagsComponent->setResolver($this->seo); return $this->metaTagsComponent; }
-
Place control macro in your .latte file.
<html> <head> {* * Will genereate all custom meta tags, * then title and finally seo tags *} {control seoMetaTags} {* Your head content *} <link rel="stylesheet" href="style.css"> </head> <body> </body> </html>
Documentation
Configuration
site_name
Name of your site, will be showed in <title> tag after/before page title and separator. Will set og:title, twitter:title, og:site_name meta properies.
default: null
options: string
description
Description of your page, will set in description, og:description, twitter:description meta properties.
default: null
options: string
type
Type of your object/content. More info about the property at ogp.me#types.
default: 'website'
options: string
image
Preview image of your website. Will set og:image, twitter:image. You can specify only Url of image, or specify url, width and height parameters.
default: null
options: string|object
separator
Separator in your <title> element.
default: '-'
options: string
customTags
Custom meta tags. Key of array item will appear name attribute and its value will appear in content attribute.
default: []
options: Array
milankyncl/nette-seo 适用场景与选型建议
milankyncl/nette-seo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 milankyncl/nette-seo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 milankyncl/nette-seo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 56
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2018-08-08