ralphjsmit/laravel-seo

[Bug] The package added prefix in the titel

chengkangzai opened this issue · 7 comments

<title>&lt;!--[if BLOCK]&gt;&lt;![endif]--&gt;The Qing | Kuala Lumpur | Pixalink Explore</title>

Hi @ralphjsmit , have been using this package for a long time but from time to time the packages acts weirdly by adding extra "IF BLOCK" to the title and the html tag

I am using exactly versions : * 1.4.3 which is the latest version.
This bug have been causing a big problem to me personally, as you can see at Pixalink Explore.
I have screenshot it for your references.
Screenshot 2024-01-30 at 1 49 38 AM

here's the config

return [
    'model' => SEO::class,

    'site_name' => config('app.name'),

    'sitemap' => '/sitemap.xml',

    'canonical_link' => true,

    'robots' => [
        'default' => 'max-snippet:-1,max-image-preview:large,max-video-preview:-1',

        'force_default' => false,
    ],

    'favicon' => '/icons/Pixalink-Logo-N-150x150.png',

    'title' => [
        'infer_title_from_url' => true,
        'suffix' => ' | '.config('app.name'),
        
        'homepage_title' => config('app.name'),
    ],

    'description' => [
        'fallback' => 'omitted.',
    ],

    'image' => [
        'fallback' => '/Pixalink Full Logo 16-9.webp',
    ],

    'author' => [
        'fallback' => 'Pixalink.io',
    ],

    'twitter' => [
        '@username' => null,
    ],
];

Thanks in advance

php 8.2.15
laravel/framework 10.43.0
ralphjsmit/laravel-seo 1.4.3

I also see this behaviour, although strangely not locally but when I deploy to server environments.

It's not pretty but it's a quick workaround. I'm not convinced this package is being maintained any longer.

@php
$seo = seo();
$pattern = '<title><!--[if BLOCK]><![endif]-->';
$replacement = '<title>';
$seo = str_replace($pattern, $replacement, $seo);
@endphp
{!! $seo !!}

Let's tag @ralphjsmit out for this....

I personally contacted him when I created this issues and he replied so I believe he's still actively maintain it..?

Not sure if we should open a PR that change the source code to get this dirty fix merged....

Hi guys, thanks for your input! The package is definitely being maintained, but I also just have my normal work to do, maintain paid packages and I also went to Laracon this week.

Anyway, these block if-conditions are comments that Livewire automatically adds so-called Morph Markers around @if conditions in your code. Likely, your Layout file is therefore also in some way parsed by Livewire.

The easy fix would have been to (temporarily) disable morph markers in your code. However, I think that should not be necessary, since I just made a change that updated the template to not use @foreach/@if anymore, but just plain PHP <?php foreach (...) : ?> statements.

Can you try version 1.4.4 and let me know whether that works?

hi @ralphjsmit it works on my local! thanks!!!

Great, thanks for letting me know! Then I will close the issue.