aerni / statamic-advanced-seo Goto Github PK
View Code? Open in Web Editor NEWComprehensive SEO addon for Statamic with flexibility in mind
Home Page: https://statamic.com/addons/aerni/advanced-seo
Comprehensive SEO addon for Statamic with flexibility in mind
Home Page: https://statamic.com/addons/aerni/advanced-seo
Hi, it's me again with another bug report ;)
I have a simple statamic site with a simple collection and advanced-seo enabled. After converting the site with php please multisite
, I get the following error when trying to access a collection entry:
the assets are not augmented, when returned by statamics rest api.
I have a custom AssetResource set up and it would be good if the addon would return the same augmented values for assets as the rest of the api. https://statamic.dev/rest-api#customizing-resources
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
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.
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
Uninstalling the aerni/advanced-seo
addon resolved the issue, indicating a potential problem with the addon in the given environment.
The SeoVariablesPolicy::view()
method should handle the provided arguments correctly without causing a server error.
The method is throwing an error due to a null
value being passed where an instance of Aerni\AdvancedSeo\Data\SeoDefaultSet
is expected.
Adding any seo tag to the site breaks it with this error, even {{ seo:dump }}
Details:
Statamic 3.3.15 Pro
Laravel 8.66.0
PHP 8.0.18
aerni/advanced-seo 1.1.5
aryehraber/statamic-captcha 1.5.2
visuellverstehen/statamic-plausible 1.2.0
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.
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.
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...
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:
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.
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!
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
<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
Thank you.
Hey there. I'm excited to see that you are working on an SEO addon. Your other packages have been top notch.
Just wondering:
I know that's a lot to ask. I'm just weighing up my options on the various Statamic SEO addons.
Thanks!
It would be nice if a flat XML sitemap could be queried through GraphQL
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
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).
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_
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] ?? '';
}
}
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?
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
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
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.
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?
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)
"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.
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.
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!
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?
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.
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.
I'm missing something obvious I'm sure but I'm trying to work out how to set Advance SEO to use a field on an entry as the OG image?
Is it possible to force Advanced SEO to use <meta name="robots" content="noindex, nofollow">
if the APP_ENV
variable is not production
? This would make it really quick for us to disable indexing on staging/development sites.
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.
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:
Looking at examples in Google's Advanced SEO Breadcrumb documentation, I see the following:
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:
<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>
<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>
Viewing the page source of one of the broken pages, I see the following:
<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>
While you can retrieve the data of specific fields such as {{ seo:title }}
, other fields including {{ seo:organization_name }}
and {{ seo:organization_logo }}
aren't available.
Please make all the seo fields configured in the control panel available for use in antlers.
Thank you.
Currently, the package is locked to 3.X via the composer file. Having support for 4.X would be greatly appreciated.
When a taxonomy route is used for a specific collection (ie: /events/tags/term) the href-lang tags are not rendered.
Steps to reproduce:
/events/tag/feast
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.
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
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" } }
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.
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.
When a content md file has a noindex property, regardless of its value, the value of seo:indexing
is set to noindex
.
This means that pages output:
<meta name="robots" content="noindex">
See demo site:
https://github.com/martyf/statamic-advanced-seo-noindex
Stripped back content, with:
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.
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:
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.