jellygnite/silverstripe-seo 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jellygnite/silverstripe-seo

Composer 安装命令:

composer require jellygnite/silverstripe-seo

包简介

An all-in-one SEO module for SilverStripe.

README 文档

README

An all-in-one SEO module for SilverStripe.

Note: For original module please see quinninteractive/silverstripe-seo.

Features

  • SEO Health Analysis in the Page Editor ![SEO Health Analysis]
  • Automatic Facebook OpenGraph meta-tag generation (can override) ![Facebook SEO Control]
  • Automatic Twitter meta-tag generation (can override) ![Twitter SEO Control]
    • Also adds a TwitterAccountName field to SilverStripe\Security\Member which is used for the creator tag. The creator is recorded when a new page is created and their Twitter account name will be used for the meta tag

Example Meta Tags Output

<link rel="canonical" href="http://sample.com/"/>
<meta property="og:title" content="Home"/>
<meta property="og:description" content="Sample Website creates boring old samples."/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://sample.com/"/>
<meta property="og:locale" content="en_GB" />
<meta property="og:site_name" content="Sample Website" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Home"/>
<meta name="twitter:description" content="Sample Website creates boring old samples."/>
<meta name="twitter:creator" content="@sample"/>
<meta name="twitter:site" content="@sample" />
<meta property="article:published_time" content="2020-04-08T00:22:10+10:00" />
<meta property="article:modified_time" content="2020-04-16T21:52:52+10:00" />

Requirements

See composer.json for details.

Installation

composer require jellygnite/silverstripe-seo

Getting Started

The necessary extensions are automatically applied after installation of this module, and a dev/build.

Writing Your Own Analysis

Health analyses have been abstracted to give developers the ability to create their own analysis checks.

To do this, you simply need to create a new class that extends Jellygnite\Seo\Analysis\Analysis.

As an example, let's create a new analysis that checks to see if Hello World! is the title of the current page.

First create the following file:

mysite\code\Analysis\HelloWorldTitleAnalysis.php

<?php

namespace Vendor\Project\Analysis;

use Jellygnite\Seo\Analysis\Analysis;

class HelloWorldTitleAnalysis extends Analysis
{
    const FAILED = 0;
    const SUCCESS = 1;

    public function run()
    {
        if (!strstr($this->getPage()->Title, 'Hello World!')) {
            return static::FAILED;
        }

        return static::SUCCESS;
    }

    public function responses()
    {
        return [
            static::FAILED  => ['The string "Hello World!" does not appear in the page title', 'danger'],
            static::SUCCESS => ['Hoorah!!! "Hello World!" appears in the page title', 'success'],
        ];
    }
}

Then dev/build. You will immediately see this new analysis running in the CMS under the "SEO Health Analysis" accordion when editing any page, then change the title to include "Hello World" and you will notice the indicator will display success.

One thing to keep in mind is that the analysis always has access to the \Page object that it is running against via $this->getPage(), so your responses can also be dynamic.

If you have created an analysis and think it would be beneficial as an addition to this module then we urge you to submit a Pull Request and you will receive full credit for your work. See CONTRIBUTING.md.

Explained: run()

You must override this method as this is where you will perform all your checks, and then return with an integer respective of the keys you define in responses(). It's a good idea to use constants that represent those integers for readability

Explained: responses()

All analyses must override the responses() method to provide response messages and the response level (which is used for the indicator).

run() should return an integer that matches a key in the array that responses() returns, for example if run() were to return 1, then using the above example the message displayed would be Hoorah!!! "Hello World!" appears in the page title with an indicator level of success

The available indicator levels are: default, danger, warning, success which are grey, red, orange and green respectively.

You can optionally prevent certain levels from displaying in the content analysis tab. The following added to the above example would cause it to only display an entry if the indicator level is not of value success:

private static $hidden_levels = [
    'success'
];

Configuration Options

enable_creator_tag

By default, this module adds an extension to \SilverStripe\Security\Member that adds a single field named TwitterAccountName, if this is set and when this particular user creates a page, the twitter:creator meta tag will automatically generate with the Members account name

You can disable this via YML:

Jellygnite\Seo\Extensions\PageSeoExtension:
  enable_creator_tag: false

Assumptions

This module assumes that you make use of the default Content field provided by \Page. If a specific page does not then you can specify one or multiple fields that contain your content.

They should be ordered in the correct order that they appear for the end user

In your \Page subclass you would have:

public function seoContentFields()
{
    return [
        'Content',
        'MyBlock.Title',
        'MyBlock.Content',
        'BottomTitle',
        'BottomContent',
    ];
}

License

BSD-3-Clause

jellygnite/silverstripe-seo 适用场景与选型建议

jellygnite/silverstripe-seo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「search」 「twitter」 「facebook」 「seo」 「optimization」 「opengraph」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jellygnite/silverstripe-seo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jellygnite/silverstripe-seo 我们能提供哪些服务?
定制开发 / 二次开发

基于 jellygnite/silverstripe-seo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 52
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-11-03