nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
165 stars 70 forks source link

Breadcrumbs List does not render in multi site setup #1207

Closed ing-ivan-31 closed 2 years ago

ing-ivan-31 commented 2 years ago

Question

Hello,

I have a Craftcms3 project with a multiple sites setup like this (they are all in the same single group):

Screen Shot 2022-09-06 at 12 37 07

My problem when i am trying to get the breadcrumbs only i am getting the homepage on the items, this is happening for all the pages

"breadcrumbList": {
   "@context": "http://schema.org/",
   "@type": "BreadcrumbList",
   "description": "Breadcrumbs list",
  "itemListElement": [
   {
    "@type": "ListItem",
    "item": "https://craft.local/",
    "name": "Homepage",
    "position": 1
    }
],
"name": "Breadcrumbs"
}

I don't know if I am missing something on the configuration of seomatic, the seomatic version used is 3.4.22

Additional context

Screen Shot 2022-09-06 at 12 58 36 Screen Shot 2022-09-06 at 13 00 56

Screen Shot 2022-09-06 at 13 01 58 Screen Shot 2022-09-06 at 13 04 01

khalwat commented 2 years ago

The first thing I would suggest it to update to the latest version, which is Version 3.4.37 as of this writing.

khalwat commented 2 years ago

Also, I notice that you're using the JSON-LD endpoint, but you're not passing in a siteId parameter? Doing so will cause it to just return the default site's metadata.

https://nystudio107.com/docs/seomatic/advanced.html#meta-container-api-endpoints

ing-ivan-31 commented 2 years ago

@khalwat, the issue persists on my environment with the version 3.4.37 and also adding the siteId parameter,

Screen Shot 2022-09-06 at 16 10 56 Screen Shot 2022-09-06 at 17 33 45 Screen Shot 2022-09-06 at 17 34 36

khalwat commented 2 years ago

Did you fill in different information for each site in SEOmatic -> Site Settings?

Screen Shot 2022-09-06 at 8 18 15 PM
ing-ivan-31 commented 2 years ago

Hi again @khalwat, thanks for the help and answers, related to your last question, I fill in all the different information for each site but I continue with the same problem, below some evidence:

Screen Shot 2022-09-07 at 9 28 27 Screen Shot 2022-09-07 at 9 28 36 Screen Shot 2022-09-07 at 9 28 45

khalwat commented 2 years ago

So I just did a test, and it seems to be working as expected.

I tried two simple tests:

URL #1: http://localhost:8003/actions/seomatic/meta-container/meta-json-ld-container/?uri=/&siteId=1

Output #1:

{
    "MetaJsonLdContainer": "<script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@type\":\"WebPage\",\"author\":{\"@id\":\"#identity\"},\"copyrightHolder\":{\"@id\":\"#identity\"},\"copyrightYear\":\"2020\",\"creator\":{\"@id\":\"#creator\"},\"dateModified\":\"2021-03-15T11:40:42-04:00\",\"datePublished\":\"2020-03-27T09:38:00-04:00\",\"headline\":\"Homepage\",\"image\":{\"@type\":\"ImageObject\",\"url\":\"http://localhost:8003/assets/site/_1200x630_crop_center-center_82_none/Screen-Shot-2022-03-22-at-12.56.42-PM.png?mtime=1650309044\"},\"inLanguage\":\"en-us\",\"mainEntityOfPage\":\"http://localhost:8003/\",\"name\":\"Homepage\",\"publisher\":{\"@id\":\"#creator\"},\"url\":\"http://localhost:8003\"}</script><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@id\":\"#identity\",\"@type\":\"LocalBusiness\",\"priceRange\":\"$\"}</script><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@id\":\"https://nystudio107.com/#creator\",\"@type\":\"Organization\",\"address\":{\"@type\":\"PostalAddress\",\"addressCountry\":\"US\",\"addressLocality\":\"Webster\",\"addressRegion\":\"NY\",\"postalCode\":\"14580\"},\"alternateName\":\"nys\",\"description\":\"We do technology-based consulting, branding, design, and development. Making the web better one site at a time, with a focus on performance, usability & SEO\",\"email\":\"info@nystudio107.com\",\"founder\":\"Andrew Welch, Polly Welch\",\"foundingDate\":\"2013-05-02\",\"foundingLocation\":\"Webster, NY\",\"image\":{\"@type\":\"ImageObject\",\"height\":\"1042\",\"url\":\"https://nystudio107-ems2qegf7x6qiqq.netdna-ssl.com/img/site/nys_logo_seo.png\",\"width\":\"1042\"},\"name\":\"nystudio107\",\"url\":\"https://nystudio107.com\"}</script><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@type\":\"BreadcrumbList\",\"description\":\"Breadcrumbs list\",\"itemListElement\":[{\"@type\":\"ListItem\",\"item\":\"http://localhost:8003\",\"name\":\"Homepage\",\"position\":1}],\"name\":\"Breadcrumbs\"}</script>"
}

URL #2: http://localhost:8003/actions/seomatic/meta-container/meta-json-ld-container/?uri=/&siteId=2

Outpu #2t:

{
    "MetaJsonLdContainer": "<script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@type\":\"WebPage\",\"author\":{\"@id\":\"#identity\"},\"copyrightHolder\":{\"@id\":\"#identity\"},\"copyrightYear\":\"2020\",\"creator\":{\"@id\":\"#creator\"},\"dateModified\":\"2021-03-15T11:40:42-04:00\",\"datePublished\":\"2020-03-27T09:38:00-04:00\",\"headline\":\"Homepage\",\"inLanguage\":\"es\",\"mainEntityOfPage\":\"http://localhost:8003/es/\",\"name\":\"Homepage\",\"publisher\":{\"@id\":\"#creator\"},\"url\":\"http://localhost:8003/es\"}</script><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@id\":\"#identity\",\"@type\":\"LocalBusiness\",\"priceRange\":\"$\"}</script><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@id\":\"https://nystudio107.com/#creator\",\"@type\":\"Organization\",\"address\":{\"@type\":\"PostalAddress\",\"addressCountry\":\"US\",\"addressLocality\":\"Webster\",\"addressRegion\":\"NY\",\"postalCode\":\"14580\"},\"alternateName\":\"nys\",\"description\":\"We do technology-based consulting, branding, design, and development. Making the web better one site at a time, with a focus on performance, usability & SEO\",\"email\":\"info@nystudio107.com\",\"founder\":\"Andrew Welch, Polly Welch\",\"foundingDate\":\"2013-05-02\",\"foundingLocation\":\"Webster, NY\",\"image\":{\"@type\":\"ImageObject\",\"height\":\"1042\",\"url\":\"https://nystudio107-ems2qegf7x6qiqq.netdna-ssl.com/img/site/nys_logo_seo.png\",\"width\":\"1042\"},\"name\":\"nystudio107\",\"url\":\"https://nystudio107.com\"}</script><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@type\":\"BreadcrumbList\",\"description\":\"Breadcrumbs list\",\"itemListElement\":[{\"@type\":\"ListItem\",\"item\":\"http://localhost:8003/es\",\"name\":\"Homepage\",\"position\":1}],\"name\":\"Breadcrumbs\"}</script>"
}

I know it's a little hard to read, but you'll see the different URLs, and two different titles: Project ENGLISH and Project SPANISH

Have you tried clearing SEOmatic's caches, or hitting the endpoints directly to see what you see there?

QUACK07 commented 2 years ago

Hi ing-ivan-31, I think you need to update the DynamicMeta.php file following this lines because right now getElementByUri function is hardcoded with__home__ and that uri doesn't exist

Line 282 self::addMetaJsonLdBreadCrumbs($siteId, $uri); line 314 public static function addMetaJsonLdBreadCrumbs(int $siteId = null, string $uri = '') line 348 $element = Craft::$app->getElements()->getElementByUri($uri, $siteId, true);

ing-ivan-31 commented 2 years ago

Hi ing-ivan-31, I think you need to update the DynamicMeta.php file following this lines because right now getElementByUri function is hardcoded with__home__ and that uri doesn't exist

Line 282 self::addMetaJsonLdBreadCrumbs($siteId, $uri); line 314 public static function addMetaJsonLdBreadCrumbs(int $siteId = null, string $uri = '') line 348 $element = Craft::$app->getElements()->getElementByUri($uri, $siteId, true);

@khalwat what do you think about this? , i made the test for only homepage in each site id and effectively the url change but when i enter other URI only i am getting the homepage check the screenshots

Screen Shot 2022-09-08 at 8 38 22 Screen Shot 2022-09-08 at 8 38 39 Screen Shot 2022-09-08 at 8 39 00 Screen Shot 2022-09-08 at 8 39 17

khalwat commented 2 years ago

So you have no element that is designated as being the homepage of the site (it would have the special URI of __home__), whether that be a single or an entry in a structure or the like?

If not, then SEOmatic can't automatically determine the home page properly for you.

ing-ivan-31 commented 2 years ago

So you have no element that is designated as being the homepage of the site (it would have the special URI of __home__), whether that be a single or an entry in a structure or the like?

If not, then SEOmatic can't automatically determine the home page properly for you.

You have right @khalwat, the homepage is missing on our craft configuration when i set the homepage all the breadcrumb lists started to work on our pages.

thank so much, for your help and support.

Screen Shot 2022-09-09 at 12 58 08 Screen Shot 2022-09-09 at 13 22 12 Screen Shot 2022-09-09 at 13 27 30