Suggestions for improving the Slim SEO plugin
-
Hello! I would like to suggest a few improvements that I think could make your plugin even better.
1. Schema. In WebPage schema markup, the inLanguage property contains the language value with a “_” separator, such as en_US, but it should be en-US. In Schema.org, the inLanguage property should contain the language value in the format en-US, that is, with a hyphen between the language code and the country code, if present. This complies with the IETF BCP 47 standard, which defines language tag formats. BCP 47 uses a hyphen (-) to separate parts of the language tag, including the language code (e.g. en) and the country code (e.g. US).
Therefore, you need to replace the get_locale() function with get_bloginfo( ‘language’ ) in the file:
\src\Schema\Types\WebPage.php
The get_bloginfo( ‘language’ ) function in WordPress returns the language code in a BCP 47 compliant format (e.g. “en-US”). This is exactly what schema.org requires for the inLanguage property.I suggest adding the “potentialAction” property to the WebPage schema markup for the “post” and “page” content types with the value of an object with the ReadAction type, so that it would display in the page code:
{ "@type": "WebPage", "@id": "https://example.com/hello-world/#webpage", "url": "https://example.com/hello-world/", ......... "potentialAction": { "@type": "ReadAction", "target": "https://example.com/hello-world/" } }
And for the main page of the site, add the “about” property in the WebPage markup with the value:
"about":{"@id":"https://example.com/#organization"}}
For the WebSite schema markup, add the “description” property with the value of the site’s Tagline and the inLanguage property:
'description' => get_bloginfo( 'description' ),
'inLanguage' => get_bloginfo( 'language' )
.For the ImageObject schema markup, add the “contentUrl” property, which will duplicate the contents of the “url” property. Because Google and Yandex prefer the “contentUrl” property:
https://developers.google.com/search/docs/appearance/structured-data/image-license-metadata#structured-data-type-definitions
https://yandex.com/support/images/schema-org.html.For the ProfilePage schema markup, add the “mainEntity” property, because it is required for ProfilePage:
"mainEntity": { "@id": "https://example.com/#/schema/person/97c3ca9bc3b52d46fa27dff34cb4fe05" }
And from the Person object, remove the “mainEntityOfPage” property on the author page, because it is not required there.
According to the documentation, the “mainEntity” property in the ProfilePage schema markup is mandatory, while “mainEntityOfPage” is not required for Person:
https://developers.google.com/search/docs/appearance/structured-data/profile-page.Add the ability to specify links to social network accounts (Facebook, X (Twitter), and others) for the “sameAs” property of the “Organization” schema markup to link the organization to its profiles elsewhere on the network. And also add links to other resources for authors in the “sameAs” property for “Person”, which will contain links to the author’s accounts in social networks and other resources.
2. Open Graph and Twitter Card. Add Open Graph tags article:author, article:publisher, twitter:creator, which will contain links to the author’s Facebook page, the organization’s Facabook page, and the author’s X (Twitter) page, respectively.
3. Date and time in ISO 8601 format, taking into account the time zone. Make the date and time in the “datePublished” and “dateModified” properties in the WebPage and Article schema markup, sitemap.xml, and Open Graph article:published_time, article:modified_time, og:updated_time tags display with the time zone set in the site settings. For example, if the Timezone in the site settings is set to UTC-5, then the time and date should be, for example, 2024-10-08T07:37:04-05:00.
Many WordPress themes on the post pages display the time tag in the code with the datatime attribute<time datetime="2024-10-08T07:37:04-05:00">
, which displays the date and time taking into account the Timezone. I assume that you need to replace the gmdate() function with wp_date() in the files:
\src\Schema\Types\WebPage.php
\src\Schema\Types\Article.php
\src\MetaTags\OpenGraph.php
\src\Sitemaps\PostType.php
Rank Math and SEOPress display the date and time taking into account the Timezone.
4. Meta robots tag. Make sure that the comment pages and replytocom, for example:
https://example.com/hello-world/comment-page-1/#comments
https://example.com/hello-world/?replytocom=1#respond
to avoid duplicate content, are not indexed using the meta tag:
<meta name='robots' content='noindex, follow' />
It is also worth prohibiting indexing of date archives.
I have disabled indexing for now with this code:add_filter('wp_robots', function($robots) { if (is_date() || (is_singular('post') && get_query_var('cpage')) || isset($_GET['replytocom'])) { return array( 'noindex' => true, 'follow' => true ); } return $robots; }, 999);
5. Unnecessary menu at the end of “Canonical URL” field on the page for adding a post. On the post adding page, there is a “Canonical URL” field, which has an option to call the menu via three dots at the end:
It is not needed there, because only a link can be specified in this field, so the selection of variables is not needed there.6. Priority of output of meta tags in HTML code. Make all meta tags appear at the top of the <head> section by setting the priority to 1 in the add_action( ‘wp_head’, [ $this, ‘output’ ], 1 ) function in the files:
\src\MetaTags\Description.php
\src\MetaTags\OpenGraph.php
\src\MetaTags\CanonicalUrl.php
\src\MetaTags\TwitterCards.php
\src\MetaTags\RelLinks.php
\src\MetaTags\LinkedIn.php
Your plugin is great, but I would like to see the improvements described above.`
- You must be logged in to reply to this topic.