简体   繁体   English

TYPO3 seo 使规范标签滑槽根线

[英]TYPO3 seo make canonical tag slide trough rootline

Using older versions of EXT:yoast I was used that once the canonical tag was defined, it was used troughout the website from that point on (if no specific new canonical was introduced)...使用旧版本的 EXT:yoast 我曾经使用过,一旦定义了规范标签,它就会从那时起在整个网站上使用(如果没有引入特定的新规范)...

Now that this feature is dealt with by the core extension SEO, this is missing and I need to fill out every single page if the whole site needs to be indicated as duplicate for another site.现在这个功能由核心扩展 SEO 处理,这是缺失的,如果整个站点需要被指示为另一个站点的重复,我需要填写每个页面。

If a 'content slide trough rootline' disturbes something there could be a boolean variable introduced that sets this behaviour only if desired...如果“content slide trough rootline”干扰了某些东西,可能会引入一个 boolean 变量,仅在需要时设置此行为......

Anybody knows how to override the core behaviour and add this for TYPO3 v9 and up?有人知道如何覆盖核心行为并将其添加到 TYPO3 v9 及更高版本吗?

First a question: if the whole site is a duplicate of another website, wouldn't it be more logical to just set the website to "noindex,nofollow" within the robots metatag?第一个问题:如果整个网站是另一个网站的副本,那么将网站设置为机器人元标记中的“noindex,nofollow”不是更合乎逻辑吗?

If you want to override the default canonical I think the easiest way would be to XCLASS the CanonicalGenerator and the method checkDefaultCanonical .如果你想覆盖默认的规范,我认为最简单的方法是 XCLASS CanonicalGenerator和方法checkDefaultCanonical

Basic example (which should work with 9, 10 and 11), within your site extension's ext_localconf.php :站点扩展的ext_localconf.php中的基本示例(应该适用于 9、10 和 11):

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Seo\Canonical\CanonicalGenerator::class] = [
    'className' => \Vendor\Ext\Xclass\CanonicalGenerator::class
];

And then (basic example of) the class:然后是 class 的(基本示例):

<?php

namespace Vendor\Ext\Xclass;

class CanonicalGenerator extends \TYPO3\CMS\Seo\Canonical\CanonicalGenerator
{
    protected function checkDefaultCanonical(): string
    {
        $canonical = parent::checkDefaultCanonical();
        return str_replace('yourdomain.ext', 'desireddomain.ext', $canonical);
    }
}

This is of course a basic example without any configuration possibilities, but this would still leave you the possibility to manually set a canonical on a page, this method is only executed when there's no other canonical available.这当然是一个没有任何配置可能性的基本示例,但这仍然会让您有可能在页面上手动设置规范,此方法仅在没有其他规范可用时执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM