nucleos / seo-bundle

Seo 组件

安装量: 10,857

依赖关系: 0

建议: 0

安全性: 0

星标: 2

关注者: 1

分支: 1

开放问题: 3

类型:symfony-bundle

1.5.0 2024-08-14 16:27 UTC

README

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Continuous Integration Code Coverage Type Coverage

NucleosSeoBundle 是基于尊重 BC 的 SonataSeoBundle 的分支,它还提供了已废弃的 NucleosSitemapBundle 的站点地图功能。

安装

打开命令行控制台,进入您的项目目录,并执行以下命令以下载此库的最新稳定版本。

composer require nucleos/seo-bundle

启用 Bundle

然后,将 Bundle 添加到项目 config/bundles.php 文件中已注册的 Bundle 列表中以启用它。

// config/bundles.php

return [
    // ...
    Nucleos\SeoBundle\NucleosSeoBundle::class => ['all' => true],
];

配置 Bundle

创建一个名为 nucleos_seo.yaml 的配置文件

# config/routes/nucleos_seo.yaml

nucleos_seo:
    resource: '@NucleosSeoBundle/Resources/config/routing/sitemap.yml'
    prefix: /

如果您想使用 symfony 缓存,您应该定义一个新的缓存池(PSR 6)并创建一个适配器将其映射到简单的缓存(PSR 16)。

nucleos_seo:
    cache:
        service: 'sitemap.cache.simple'

framework:
    cache:
        pools:
            sitemap.cache:
                adapter: cache.app
                default_lifetime: 60

services:
    sitemap.cache.simple:
        class: 'Symfony\Component\Cache\Psr16Cache'
        arguments:
            - '@sitemap.cache'

添加静态条目

您可以在 yaml 配置中添加静态条目。

# config/packages/nucleos_seo.yaml

nucleos_seo:
    static:
        - { url: 'http://example.com', priority: 75, changefreq: 'weekly' }

添加自定义站点地图

如果您想创建自定义站点地图,您只需创建一个使用 Nucleos\SeoBundle\Sitemap\SitemapServiceInterface 的服务,并使用 nucleos_seo.sitemap 标签服务。

    <service id="App\Sitemap\CustomSitemap">
      <tag name="nucleos_seo.sitemap"/>
    </service>

许可证

此 Bundle 在 MIT 许可证 下。