Coder Social home page Coder Social logo

aerni / statamic-advanced-seo Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 4.0 1.78 MB

Comprehensive SEO addon for Statamic with flexibility in mind

Home Page: https://statamic.com/addons/aerni/advanced-seo

PHP 89.29% CSS 0.02% JavaScript 0.32% Vue 4.77% Blade 1.90% XSLT 1.90% Antlers 1.81%
statamic statamic-addon

statamic-advanced-seo's People

Contributors

aerni avatar dependabot[bot] avatar faustbrian avatar narretz avatar tobimori avatar valschr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

statamic-advanced-seo's Issues

How to use it with blade?

Nice addon. It seems the most complete solution so far but my problem is that we are using blade and I don't know how to fetch the data.
I've tried
Statamic::tag('seo:title')->fetch() to get the site title.
Also, in a template used by a blueprint I would need to have Entry meta_title | Site title

Issue with SeoVariablesPolicy::view() Causing Server Error in Statamic Application

Description

After a recent update, our Statamic application started encountering a 500 Server Error for non-super users. The error is specifically related to the Aerni\AdvancedSeo\Policies\SeoVariablesPolicy::view() method. The method is expecting an argument of type Aerni\AdvancedSeo\Data\SeoDefaultSet, but null is provided instead.

Error Message

Aerni\AdvancedSeo\Policies\SeoVariablesPolicy::view(): Argument #2 ($set) must be of type Aerni\AdvancedSeo\Data\SeoDefaultSet, null given, called in /path/to/vendor/aerni/advanced-seo/src/Policies/SeoVariablesPolicy.php on line 15

Environment

  • Application Name: GRANSHAN Competition
  • Laravel Version: 10.40.0
  • PHP Version: 8.2.14
  • Composer Version: 2.6.6
  • Statamic Version: 4.43.0 PRO
  • Advanced SEO Addon Version: 2.4.0

Troubleshooting Steps Taken

  1. Checked for compatibility issues.
  2. Reviewed Advanced SEO configuration files.
  3. Cleared application caches.
  4. Tested in both production and local development environments, encountering the same issue.

Temporary Solution

Uninstalling the aerni/advanced-seo addon resolved the issue, indicating a potential problem with the addon in the given environment.

Expected Behavior

The SeoVariablesPolicy::view() method should handle the provided arguments correctly without causing a server error.

Actual Behavior

The method is throwing an error due to a null value being passed where an instance of Aerni\AdvancedSeo\Data\SeoDefaultSet is expected.

Multi-site error in Windows

This is a follow-up to #56

The error persists, and I'm pretty sure it's a problem with advanced-seo, not the multisite feature. Even after converting a clean statamic 3 install to multisite, I get the error seen here: https://flareapp.io/share/omwrgWR5#F109

From what I can tell, the problem is in Aerni \ AdvancedSeo \ Data \ SeoDefaultSet :blueprint function.

$blueprint = Defaults::blueprint("{$this->type}::{$this->handle}");

When you go to "cp/advanced-seo/site/general", and you don't have multisite configured, "{$this->type}::{$this->handle}" will be "site::general", but when you multisite configured, "{$this->type}::{$this->handle}" will be for example "site/default::general", for which no blueprint exists, and the error is thrown. The same is true for collections settings etc.

What's noteworthy is that this only happens the second time after you go to "cp/advanced-seo/site/general", because advanced-seo will create the localizations initially.

Titles not reflecting current entry

When viewing or sharing, the og:title and twitter:title do not reflect the current entry's title.

Everything else is correct: image, url, content, etc.

This also happens with other collections on the same site.

I have cleared caches, tried different browsers, and machines.

Looking for any suggestions...

Duplicate ID's after updating + SeoDefaultSet make() error

I just updated Statamic + AdvancedSEO to the latest version, but got this error over the complete frontend:

[2024-02-06 12:44:59] local.ERROR: Too few arguments to function Illuminate\Foundation\Application::make(), 0 passed in /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoDefaultSet.php on line 213 and at least 1 expected {"userId":2,"exception":"[object] (ArgumentCountError(code: 0): Too few arguments to function Illuminate\\Foundation\\Application::make(), 0 passed in /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoDefaultSet.php on line 213 and at least 1 expected at /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:938)
[stacktrace]
#0 /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoDefaultSet.php(213): Illuminate\\Foundation\\Application->make()
#1 /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoVariables.php(200): Aerni\\AdvancedSeo\\Data\\SeoDefaultSet->blueprint()
#2 /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoVariables.php(133): Aerni\\AdvancedSeo\\Data\\SeoVariables->blueprint()
#3 /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoVariables.php(142): Aerni\\AdvancedSeo\\Data\\SeoVariables->defaultData()
#4 /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoDefaultSet.php(152): Aerni\\AdvancedSeo\\Data\\SeoVariables->withDefaultData()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(240): Aerni\\AdvancedSeo\\Data\\SeoDefaultSet->Aerni\\AdvancedSeo\\Data\\{closure}()
#6 /var/www/html/vendor/aerni/advanced-seo/src/Data/SeoDefaultSet.php(152): Illuminate\\Support\\Collection->each()
#7 /var/www/html/vendor/aerni/advanced-seo/src/Actions/GetAugmentedDefaults.php(14): Aerni\\AdvancedSeo\\Data\\SeoDefaultSet->ensureLocalizations()
#8 /var/www/html/vendor/aerni/advanced-seo/src/Actions/GetSiteDefaults.php(26): Aerni\\AdvancedSeo\\Actions\\GetAugmentedDefaults::handle()
#9 [internal function]: Aerni\\AdvancedSeo\\Actions\\GetSiteDefaults::Aerni\\AdvancedSeo\\Actions\\{closure}()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(560): array_map()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\\Support\\Arr::map()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(404): Illuminate\\Support\\Collection->map()
#13 /var/www/html/vendor/aerni/advanced-seo/src/Actions/GetSiteDefaults.php(26): Illuminate\\Support\\Collection->flatMap()
#14 /var/www/html/vendor/spatie/blink/src/Blink.php(306): Aerni\\AdvancedSeo\\Actions\\GetSiteDefaults::Aerni\\AdvancedSeo\\Actions\\{closure}()
#15 /var/www/html/vendor/statamic/cms/src/Support/Blink.php(18): Spatie\\Blink\\Blink->once()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(355): Statamic\\Support\\Blink->__call()
#17 /var/www/html/vendor/aerni/advanced-seo/src/Actions/GetSiteDefaults.php(24): Illuminate\\Support\\Facades\\Facade::__callStatic()
#18 /var/www/html/vendor/aerni/advanced-seo/src/View/BaseCascade.php(38): Aerni\\AdvancedSeo\\Actions\\GetSiteDefaults::handle()
#19 /var/www/html/vendor/aerni/advanced-seo/src/View/ViewCascade.php(33): Aerni\\AdvancedSeo\\View\\BaseCascade->withSiteDefaults()
#20 /var/www/html/vendor/aerni/advanced-seo/src/View/BaseCascade.php(31): Aerni\\AdvancedSeo\\View\\ViewCascade->process()
#21 /var/www/html/vendor/aerni/advanced-seo/src/ServiceProvider.php(214): Aerni\\AdvancedSeo\\View\\BaseCascade::from()
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Concerns/ManagesEvents.php(162): Aerni\\AdvancedSeo\\ServiceProvider->Aerni\\AdvancedSeo\\{closure}()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(455): Illuminate\\View\\Factory->Illuminate\\View\\Concerns\\{closure}()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(286): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(266): Illuminate\\Events\\Dispatcher->invokeListeners()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Concerns/ManagesEvents.php(177): Illuminate\\Events\\Dispatcher->dispatch()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(188): Illuminate\\View\\Factory->callComposer()
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(159): Illuminate\\View\\View->renderContents()
#29 /var/www/html/vendor/statamic/cms/src/View/View.php(100): Illuminate\\View\\View->render()
#30 /var/www/html/vendor/statamic/cms/src/Http/Responses/DataResponse.php(146): Statamic\\View\\View->render()
#31 /var/www/html/vendor/statamic/cms/src/Http/Responses/DataResponse.php(42): Statamic\\Http\\Responses\\DataResponse->contents()
#32 /var/www/html/vendor/statamic/cms/src/Structures/Page.php(388): Statamic\\Http\\Responses\\DataResponse->toResponse()
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(900): Statamic\\Structures\\Page->toResponse()
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(885): Illuminate\\Routing\\Router::toResponse()
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(805): Illuminate\\Routing\\Router->prepareResponse()
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#37 /var/www/html/vendor/statamic/cms/src/StaticCaching/Middleware/Cache.php(60): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\StaticCaching\\Middleware\\Cache->handle()
#39 /var/www/html/vendor/statamic/cms/src/Http/Middleware/AuthGuard.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\AuthGuard->handle()
#41 /var/www/html/vendor/statamic/cms/src/Http/Middleware/AddViewPaths.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\AddViewPaths->handle()
#43 /var/www/html/vendor/statamic/cms/src/Http/Middleware/Localize.php(38): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\Localize->handle()
#45 /var/www/html/vendor/statamic/cms/src/Http/Middleware/HandleToken.php(13): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\HandleToken->handle()
#47 /var/www/html/vendor/statamic/cms/src/Http/Middleware/StacheLock.php(29): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\StacheLock->handle()
#49 /var/www/html/vendor/heidkaemper/statamic-toolbar/src/Middleware/InjectToolbar.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#50 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Heidkaemper\\Toolbar\\Middleware\\InjectToolbar->handle()
#51 /var/www/html/app/Http/Middleware/CheckClientLinkRedirect.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\CheckClientLinkRedirect->handle()
#53 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#54 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#55 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#56 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#57 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#58 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#59 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#60 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#61 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Session\\Middleware\\StartSession->handle()
#62 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#63 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#64 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#65 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#66 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#67 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(805): Illuminate\\Pipeline\\Pipeline->then()
#68 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\\Routing\\Router->runRouteWithinStack()
#69 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\\Routing\\Router->runRoute()
#70 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\\Routing\\Router->dispatchToRoute()
#71 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#72 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#73 /var/www/html/vendor/statamic/cms/src/Http/Middleware/StopImpersonating.php(12): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#74 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\StopImpersonating->handle()
#75 /var/www/html/vendor/statamic/cms/src/Http/Middleware/DisableFloc.php(17): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#76 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\DisableFloc->handle()
#77 /var/www/html/vendor/statamic/cms/src/Http/Middleware/CheckMultisite.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#78 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\CheckMultisite->handle()
#79 /var/www/html/vendor/statamic/cms/src/Http/Middleware/CheckComposerJsonScripts.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#80 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\CheckComposerJsonScripts->handle()
#81 /var/www/html/vendor/statamic/cms/src/Http/Middleware/PoweredByHeader.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#82 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\PoweredByHeader->handle()
#83 /var/www/html/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(59): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#84 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle()
#85 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#86 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#87 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#88 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#89 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#90 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#91 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#92 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#93 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#94 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#95 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#96 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\HandleCors->handle()
#97 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#98 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#99 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#100 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#101 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#102 /var/www/html/public/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle()
#103 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(16): require_once('...')
#104 {main}
"} 

Also in the CP I see duplicated ID's for all content files of the SEO addon:
Screenshot 2024-02-06 at 13 51 31
When regenerating nothing happens, it just refreshes the page.

Any idea what it can be? When removing the complete /seo/ folder inside content it is working fine, but that is of course not what we want on the production server.

Weird button labels

When going to my Collection in Statamic I see weird button labels. Is this a translation issue?

Screenshot 2023-08-02 at 12 42 39

Use field value as default for collections

Hi,

Is it possible to use field values as default for a collection?
For example: the news collection has a field 'preview_text' and I want to configure this text as the default description. Would that be possible?

Thanks!

Collection segment missing from hreflang tags for taxonomy terms

Summary
After installing and configuring the Advanced SEO addon, I ran an Ahrefs Site Audit and received the following error on all my taxonomy terms:

Hreflang to redirect or broken page

The cause appears to be that the hreflang tags are missing the collection segment.

Expected behavior
Since the website uses a single language, the hreflang tag should match the canonical tag:

<link rel='alternate' href="http://www.domain.com/articles/categories/term" hreflang="en-US" >
<link rel="canonical" href="http://www.domain.com/articles/categories/term">

Actual behavior
Viewing the page source of one of the broken taxonomy pages, I see the following:

<link rel='alternate' href="http://www.domain.com/categories/term" hreflang="en-US" >
<link rel="canonical" href="http://www.domain.com/articles/categories/term">

Notice that the hreflang tag is missing the "article" collection segment.

To reproduce the issue

  1. Clone the https://github.com/markguleno/statamic-advanced-seo-hreflang repository
  2. Run "composer install"
  3. Copy ".env.example" to ".env" and configure the "APP_URL" appropriately (e.g. "APP_URL=http://www.hreflang.test")
  4. Generate an application key by running "php artisan key:generate"
  5. Visit the site's home page
  6. Click on the link to visit the "term" page
  7. View the page source
  8. Notice that the "canonical" link is correct, but the "hreflang" link is missing the "articles" segment:
<link rel='alternate' href="http://www.hreflang.test/categories/term" hreflang="en-US" >
<link rel="canonical" href="http://www.hreflang.test/articles/categories/term">

Workaround
Since the website uses a single language, I disabled the hreflang tag by commenting a single line in the Advanced SEO addon source code located at /vendor/aerni/advanced-seo/resources/views/head.antlers.html:

{{# Hreflang #}}
{{# partial src="advanced-seo::snippets/hreflang" #}}

To create the site used to demonstrate the issue

  1. Install a new Statamic v3.3.12 blank site (e.g. "statamic new hreflang")
  2. Create a superuser by running "php please make:user"
  3. Edit ".env" and configure the "APP_URL" appropriately (e.g. "APP_URL=http://www.hreflang.test")
  4. Install the Advanced SEO v1.1.2 addon ("composer require aerni/advanced-seo")
  5. Disable the social images generator
  6. In the layout template, replace the "<title>" tag with the "{{ seo:head }}" tag
  7. Create a "Categories" taxonomy
  8. Remove the "Author" and "Template" fields from the "Categories" blueprint
  9. Create a new term called "Term" in the "Categories" taxonomy
  10. Create an "Articles" collection
  11. Configure the "Articles" colection to use the "Categories" taxonomy
  12. Create the "/resources/views/articles/categories" directory
  13. Create a "/resources/views/articles/categories/show.antlers.html" file
  14. Update the show template file created above to contain "Please view the source of this page."
  15. Update the "Home" page content to link to "/articles/categories/term"

Thank you.

Just a few questions

Hey there. I'm excited to see that you are working on an SEO addon. Your other packages have been top notch.

Just wondering:

  • Will blade be supported?
  • Will the add-on generate reports and SEO recommendations?
    • If so, how will SEO checks performed? I think a lot of SEO plugins make the mistake of analysing back-end content, when they should really be analysing the front-end and what is being shown to the visitor on each public url.
  • Will you be including redirects and automatic redirects for multisite environments?

I know that's a lot to ask. I'm just weighing up my options on the various Statamic SEO addons.

Thanks!

Statamic 4 + SSG won't Generate

When I run php please ssg:generate I get this error:

Gathering content to be generated...

   Error

  Call to a member function url() on null

  at vendor/statamic/ssg/src/Request.php:51
     47▕     }
     48▕
     49▕     public function getPathInfo(): string
     50▕     {
  ➜  51▕         return $this->page->url();
     52▕     }
     53▕
     54▕     public function path()
     55▕     {

      +34 vendor frames

  35  [internal]:0
      Illuminate\Support\Collection::Illuminate\Support\Traits\{closure}(Object(Statamic\Entries\Entry))
      +21 vendor frames

  57  please:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

As soon as I uninstall it, it generates fine.

My project:
Environment
Application Name: Keepme
Laravel Version: 10.12.0
PHP Version: 8.1.17
Composer Version: 2.5.5
Environment: local
Debug Mode: ENABLED
URL: keepme.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 3
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.3.0 PRO

Statamic Addons
aerni/advanced-seo: 2.1.1
statamic/ssg: 2.0.0
stefangalescu/statamic-heroicons: 2.1

[FR] Store settings in mysql or S3

I am working on a multi tenant statamic app and my only issue atm is that no SEO plugin supports storing the settings in eloquent or even in a s3 bucket.

The ideal SEO plugin would store those settings in a custom table in the SQL database. The alternative would be to store the settings in an S3 bucket.

The only issues are the settings that get stored in content/advanced-seo, everything else works perfectly when using the statamic eloquent driver (https://github.com/statamic/eloquent-driver).

Button texts missing

When using locale different from en (defined in app.locale), only the text key shows in some cases.

See attached examples.

nb

en

Browsershot Error When Generating SEO Images

I am running into an error when I try to generate seo images on production server.

The error is :

/var/www/html/vendor/spatie/browsershot/bin/browser.cjs:373
            await page.waitForSelector(request.options.waitForSelector, request.options.waitForSelectorOptions ?? undefined);


SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

I am running :
_Laravel v10.30
Statamic CMS v4.31.0
Advanced SEO v2.3.0

[email protected]
Node v18.17.1 NPM v9.6.7_

Issue with `route:list` when this package is installed

Hi! I've been meaning to give this package a go. During testing, I noticed that the route:list command started throwing an error after installing this package: Undefined array key 2. Looks like the constructor of SeoDefaultsController expects at least three segments from the Request object, which in the route:list command probably doesn't exist. It might also be a misconfiguration on my part...

The change below took care of that in my installation. Not sure if there's any downside to doing this.

class SeoDefaultsController extends CpController
{
    public function __construct(Request $request)
    {
-        $this->type = $request->segments()[2];
+        $this->type = $request->segments()[2] ?? '';
    }
}

Localization doesn't show

On the SEO tab of the Pages collection, the strings do not show up correctly. Instead, a placeholder is shown for some of them. Why?

image

Environment
Laravel Version: 9.52.7
PHP Version: 8.2.4
Composer Version: 2.4.3
Environment: local

Statamic
Addons: 1
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.4.11 PRO

Statamic Addons
aerni/advanced-seo: 2.0.6

Fix breadcrumbs for collection taxonomies

The breadcrumbs are missing the collection segment on a collection taxonomy index and collection taxonomy show page.

https://site.com/collection/taxonomy
https://site.com/collection/taxonomy/term

Improve Sitemap generation on larger sites with small memory limit (128M)

Currently, when rendering the sitemap on our Statamci site with a default memory limit of 128M and around 450 pages across all languages in two collections, all requests fail with a memory limit error.

2024/01/16 14:06:57 [error] 915416#915416: *709626 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/enfore-vnt2l/next.enfore.com/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php on line 310; PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /home/enfore-vnt2l/next.enfore.com/vendor/symfony/error-handler/Error/FatalError.php on line 1" while reading response header from upstream, client: 64.252.88.246, server: next.enfore.com, request: "GET /sitemap.xml HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.3-fpm-enfore-vnt2l.sock:", host: "www.enfore.com"

It'd be great if there was a way for sitemap generation to be "off loaded" in the background (e.g. in a queue worker on changes) instead of being on demand so we can avoid setting a high memory limit.

Not possible to translate SEO title for custom routes

I've tried to translate the seo title and description for a custom route but without success. This is the route.php:

Route::statamic('/custom', 'custom.index', [
            'seo_enabled' => true,
            'seo_title' => __('seo.cart_title'),
            'seo_description' => __('seo.cart_description')]);

And the HTML for this route is outputting:
<title> seo.cart_title | SiteName </title>

The correct lang folder and file are set up with translations for the current user locale.

Is this something that I can fix myself or does it need to be inside the addon?

Graphql support

It would be great to expose the SEO data via graphql for using statamic as a headless CMS.

So far I cannot see anything being exposed via gql.

It looks like not even the SEO Pro addon by Statamic themselves does this correctly, so there may be an opportunity here to get an edge over the competition. (I have literally no idea how difficult this is)

Allow custom @auto for other fields

"Meta title" by default uses @auto to inherit the value from the title field, because every entry in statamic has a title field. It would be cool if you could use @auto for example for "meta description" and then select a field in the collection / taxonomy type from which to inherit.

Provide value fallbacks

If you install the addon into an existing site, you'd have to go through and save each entry to ensure the meta title and other values are output correctly. The addon should provide sensitive fallback values if an entry has no SEO values saved. An alternative could be a migration script.

GraphQL seo>view>head missing json+ld script tag

Hi @aerni,

first of all, thank you for this addon. It really seems to be the drop-in-and-forget SEO solution for GraphQL-projects with Statamic I was looking for. However I came across an issue with the latest version (though I haven't checked earlier ones).

When performing a query like:

fragment SEO on EntryInterface {
  seo {
    view {
        head
    }
  }
}

the result looks like this:

"\n    <title>Pentagonal Landscapes | Acre Studio Local</title>\n\n\n\n\n\n\n\n    \n        <link rel='alternate' href=\"http://acre.studio.statamic.test/work/pentagonal-landscapes\" hreflang=\"en-US\" >\n    \n        <link rel='alternate' href=\"http://acre.studio.statamic.test/work/pentagonal-landscapes\" hreflang=\"x-default\" >\n    \n\n\n\n\n\n    <link rel=\"canonical\" href=\"http://acre.studio.statamic.test/work/pentagonal-landscapes\">\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n{\"@context\":\"https:\\/\\/schema.org\",\"@type\":\"BreadcrumbList\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\/\\/acre.studio.statamic.test\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Work\",\"item\":\"http:\\/\\/acre.studio.statamic.test\\/work\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Pentagonal Landscapes\",\"item\":\"http:\\/\\/acre.studio.statamic.test\\/work\\/pentagonal-landscapes\"}]}\n\n\n\n<meta property=\"og:type\" content=\"website\">\n\n\n    <meta property=\"og:site_name\" content=\"Acre Studio Local\">\n\n\n\n    <meta property=\"og:locale\" content=\"en-US\">\n\n\n\n    <meta property=\"og:title\" content=\"Pentagonal Landscapes\">\n\n\n\n    <meta property=\"og:url\" content=\"http://acre.studio.statamic.test/work/pentagonal-landscapes\">\n\n\n\n    \n        <meta property='og:locale:alternate' content=\"en-US\" >\n    \n        <meta property='og:locale:alternate' content=\"x-default\" >\n    \n\n\n\n\n\n\n\n\n\n    <meta name=\"twitter:card\" content=\"summary\">\n\n\n\n    <meta name=\"twitter:title\" content=\"Pentagonal Landscapes\">\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"

where the json-ld data is missing its <script type="application/ld+json"> tag

{\"@context\":\"https:\\/\\/schema.org\",\"@type\":\"BreadcrumbList\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\/\\/acre.studio.statamic.test\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Work\",\"item\":\"http:\\/\\/acre.studio.statamic.test\\/work\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Pentagonal Landscapes\",\"item\":\"http:\\/\\/acre.studio.statamic.test\\/work\\/pentagonal-landscapes\"}]}

I also wound't mind if all these excess \n could be stripped, so it looks a bit nicer.

Other than that, thanks again for your great work!

App\Models\User database user error when viewing setting pages.

I'm using database users in Statamic and with this addon I get the following error when opening SEO related pages (for example: /cp/advanced-seo/collections). The error not showing up for super users, only users with permissions (all SEO permissions are enabled).

Aerni\AdvancedSeo\Policies\SeoVariablesPolicy::index(): Argument #1 ($user) must be of type Statamic\Contracts\Auth\User, App\Models\User given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php on line 811

Here is the full stacktrace of this error:
stacktrace.txt

How to fix this? Is this something in my install or addon-related?

Set SEO for custom views / layouts

Hello,

I'm using Simple Commerce Addon and want to add Advanced SEO data to the /cart & /checkout pages. These are custom defined routes (so not linked to a collection/entry). Is it possible to send seo data in the route definition for these pages?
The {{ seo:head }} and {{ seo:body }} are not outputting anything on those pages (also not default site SEO settings).
I've tried this but that wasn't working:
Route::statamic('/cart', 'checkout.cart', ['seo_title' => 'Your Cart']);

Would love to see it working for custom web routes as well.

Make view composer configurable

Hey, I just encountered an issue with this package that could be easily resolved, but I wanted to ask before submitting a pull request. The issue arises here: ServiceProvider.php Line 195. The package assumes that we want to apply the view composer to all views in the entire project. This works well if you're running Statamic as a standalone project. However, when using Statamic as part of an existing project that stores views in another directory—let's say resources/views/statamic—the view composer still applies to everything outside of that directory. In my case, I would need a pattern like statamic.* instead of *. I could submit a PR to make this configurable.

SEO generate images saving on local

I have changed the config to generate and save SEO images into a cloud container however when I run php artisan SEO:generate-images, it creates a new folder in the local disk and save the images there, however, the metadata is sent to the cloud container.

Google Search Console - JSON-LD Breadcrumbs - Invalid object type for field "itemListElement"

Summary

After adding my production website to the Google Search Console, I get the following error on pages (other than the home page):

Invalid object type for field "itemListElement"

The primary cause is that the "itemListElement" value array is wrapped in double quotes and the each item in the array has its double quotes escaped.

I verified this as follows:

  1. Test the broken version
    a. View the source of one of the broken pages
    b. Copy the contents of the <script type="application/ld+json"> tag into the Google Rich Results Test "CODE" tab, replacing the existing <script> tag content
    c. Click the "RUN TEST" button
    d. The test fails with an "Invalid object type for field "itemListElement" error
  2. Create and test a fixed version
    a. View the source of one of the broken pages
    b. Copy the contents of the <script type="application/ld+json"> tag into a text editor
    c. Remove the double quotes around the "itemListElement" value array
    d. Search and replace the escaped quotes by replacing " with "
    e. Search and replace the escaped slashes by replacing \/ with / & / with /
    f. Copy and paste this fixed version into the Google Rich Results Test "CODE" tab, replacing the existing <script> tag content
    g. Click the "RUN TEST" button
    h. The test passes

Additional comments

  1. The "id" attribute should be named "@id" as per Schema.org itemListElement
  2. The "itemListElement" value array doesn't need a "@context" attribute
  3. Unlike Schema.org's example where the "name" attribute is a child of "item", (Google's breadcrumb example)[https://developers.google.com/search/docs/advanced/structured-data/breadcrumb] simply puts the "name" attribute at the same level as "item" and set's the "item" attribute's value to the url
  4. The slashes don't need to be escaped

Expected behavior

Looking at examples in Google's Advanced SEO Breadcrumb documentation, I see the following:

  1. The "itemListElement" value array isn't enclosed in quotes
  2. The "itemListElement" value array elements attribute names and string values are quoted, but they don't have their double quotes escaped because of point number 1 above
  3. The "@context" attribute is only used at the root level of the JSON+LD tree

Looking at Schema.org definition of itemListElement "JSON-LD" tab, the "id" attribute should be named "@id"

Neither of those examples uses "@type": "Thing"

Therefore, the generated breadcrumb should look like either one of the following:

Schema.org itemListElement format

<script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "BreadcrumbList",
        "itemListElement": [{
            "@type": "ListItem",
            "position": 1,
            "item": {
                "id": "http://www.domain.com",
                "name": "Home"
            }
        },{
            "@type": "ListItem",
            "position": 2,
            "item": {
                "id": "http://www.domain/page",
                "name": "Page"
            }
        }]
    }
</script>

Google breadcrumb format

<script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "BreadcrumbList",
        "itemListElement": [{
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "http://www.domain.com"
        },{
            "@type": "ListItem",
            "position": 2,
            "name": "Page",
            "item": "http://www.domain/page"
        }]
    }
</script>

Actual behavior

Viewing the page source of one of the broken pages, I see the following:

Advanced SEO v1.1.3 breadcrumb format

<script type="application/ld+json">
    {
        "@context":"https:\/\/schema.org",
        "@type":"BreadcrumbList",
        "itemListElement": "[{
            \"@context\":\"https:\\\/\\\/schema.org\",
            \"@type\":\"ListItem\",
            \"position\":1,
            \"item\": {
                \"@type\":\"Thing\",
                \"id\":\"http:\\\/\\\/www.domain.com\",
                \"name\":\"Home\"
            }
        },{
            \"@context\":\"https:\\\/\\\/schema.org\",
            \"@type\":\"ListItem\",
            \"position\":2,
            \"item\": {
                \"@type\":\"Thing\",
                \"id\":\"http:\\\/\\\/www.domain\\\/page\",
                \"name\":\"Page\"
            }
        }]"
    }
</script>

Versions used

  • Statamic v3.3.13
  • Advanced SEO v1.1.3

Statamic 4 Support

Currently, the package is locked to 3.X via the composer file. Having support for 4.X would be greatly appreciated.

Customize which fields are shown in the SEO tab / page

As a developer / site owner I might not want to expose all the possible fields to site authors. Or maybe the frontend doesn't use Twitter metadata, so I might not want to show these fields to not confuse the authors.

Error after Update

Hallo,
I just updated statamic from v3.3.43 => v3.3.49 and now I get following error:
Declaration of Aerni\AdvancedSeo\Data\SeoDefaultSet::in(string $locale): ?Aerni\AdvancedSeo\Data\SeoVariables must be compatible with Statamic\Contracts\Globals\GlobalSet::in($locale)
in
vendor / aerni / advanced-seo / src / Data / SeoDefaultSet.php: 141

Do you have any suggestion how I can fix this?
Thanks Jan

Variables for JSON-LD Schema

I'd like to define a JSON-LD Schema on a collection. So every entry will have it's own specific rich snippet data.

Is there a way to use variables in the json data, so a specific JSON-LD schema will be generated per entry ?

For example:

{ "@context":"https://schema.org/", "@type":"Product", "name":"{{ name }}", "image":"{{ image }}", "description":"{{ description }}", "brand":{ "@type":"Brand", "name":"{{ brand }}" } }

{ "@context":"https://schema.org/", "@type":"Product", "name":"Name of product", "image":"https://mywebsite.com/image.jpg", "description":"Product description", "brand":{ "@type":"Brand", "name":"Name of brand" } }

Add config option to define base URLs for GraphQL view queries

Querying e.g. seo > view > head uses the root URL of the statamic application for generating canonical links, which often doesn't make sense for a headless app. The favicon on the other hand seems to be a relative URL, which also breaks on a headless setup. I think it would be nice if there could be config options for app_url or frontend_url and asset_url, although Statamic only seems to be using the corresponding ENV vars APP_URL and ASSET_URL for CLI tools.

seoMeta query: Maximum execution time of 30 seconds exceeded

When upgrading to Statamic version 4.32.0 our query for fetching seo related data fails. Statamic returns immediate the following error:Maximum execution time of 30 seconds exceeded

Query is as simple as:

query MyQuery {
  seoMeta(id: "home") {
    computed {
      title
    }
  }
}

However I won't see any direct relation within this update.

Add option for custom title separator

It might be handy to be able to set a custom title separator in the general site defaults in addition to the pre-defined options.

It probably doesn't make sense to make this configurable on the content defaults and each entry/term, though. If you want to go custom on an entry/term, you can always disable the site name and write a fully custom meta title.

BadMethodCallException - Call to undefined method Statamic\Entries\Entry::title()

Summary

After upgrading to Advanced SEO v1.1.4, visiting a page in a collection (https://www.domain.com/collection/page) results in a BadMethodCallException - Call to undefined method Statamic\Entries\Entry::title() error:

title-error

Workaround

Either rolling back to Advanced SEO v1.1.3 or commenting out the {{ seo:head }} tag in layout.antlers.html allows the page to load properly.

Versions used

  • Statamic v3.3.13
  • Advanced SEO v1.1.4
  • PHP 8.1.6
  • Laravel 9.5.1

Invalid route action

UnexpectedValueException
Invalid route action: [Aerni\AdvancedSeo\Http\Controllers\Aerni\AdvancedSeo\Http\Controllers\Cp\ConditionsController]

at

Illuminate\Routing\RouteAction::makeInvokable
vendor/laravel/framework/src/Illuminate/Routing/RouteAction.php:92

caused by

    protected static function makeInvokable($action)
    {
        if (! method_exists($action, '__invoke')) {
            throw new UnexpectedValueException("Invalid route action: [{$action}].");
        }
 
        return $action.'@__invoke';
    }

Statamic 3.4.4
PHP 8.2
Laravel 8.83.27

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.