Open snibbo71 opened 3 years ago
Probably having a similar issue here. Based on Google's and the BreadcrumbList Schema.org Type documentation I also assume a full URL is required. Might be a good idea to use siteMetadata.siteUrl
(from gatsby-config
) or the base URL provided by Yoast / WordPress. As the schema is taken directly from the GraphQL endpoint this might be an issue for wp-graphql-yoast-seo. Still posting this here as I am not sure where the actual problem originates.
I tend to agree, I think it is actually an issue in the transmitter side rather than this plug-in. I've not had a chance to dig into the code for that properly, but the code for this plug-in looks like it just passes the data through.
I'm not sure where the best practise would suggest the change should be made, should it be captured here and rewritten to add the full URL based on your Gatsby config (site.siteMetadata.siteUrl ?) or should it just be done on the WordPress/Yoast side?
So, it actually looks like it's the gatsby-source-wordpress which is removing the website prefix - which it does naturally for every other link or image src it finds in the nodes.
So, this is actually beyond the control (I think) of the SEO plugin.
I've gotten around it by using the 'searchAndReplace' configuration option of gatsby-source-wordpress, which works for me because I have my WordPress instance on a completely different hostname to the Gatsby generated site. If you're interested, I now have this set in the gatsby-config.js file for the gatsby-source-wordpress plugin.
options: { ..... url: process.env.GATSBY_GRAPHQL, searchAndReplace: [ { search: "https://wpadmin", replace: "https://www" } ], ..... }
Digging further this actually appears to be completely knackered due to the way the gatsby-source-wordpress plugin works.
From what I can see, it has a 'replaceNodeHtmlLinks' method which just blanket blats any https://yourWPsite.domain.com/ prefixes using a search and replace regex. It does this for every node it creates, and there's no way to tell it to ignore certain aspects of the node. It runs across the whole node in string format...
The only possible way I could see of getting this to work is to have this plugin build the 'seo' section of the node (Sorry, I know my terminology is off!) with a different URL prefix to the WP URL
For me, this could simply be set to https://www.mydomain.com instead of the actual WordPress install domain, since my install domain is https://wpadmin.mydomain.com - I'd not need to do anything extra. But perhaps for others, they may need to have the SEO section added with a 'https://dummydomain' replacing their wordpress URL, which then the SearchAndReplace could look for to switch back, hopefully running after this blanket search and replace has run.
That's a mess. But I can't see any way around it. And I can't see how that can be achieved except on the WordPress Yoast SEO-Gatsby plugin side because it's that which fetches the schema from Yoast, and it's Yoast that puts the WordPress domain in where it needs to be
So, I've created a fork at https://github.com/snibbo71/wp-graphql-yoast-seo which resolves this issue, but of course has to be done in the WordPress side not the Gatsby side. Given that it's perhaps a pretty specific use-case I'm not sure if Ash would want to incorporate it in the main - though if he does, as a configuration option perhaps, that'd be ideal :)
Breadcrumbs are giving an incorrectly formatted URL in the ID field. My understanding is this must be a full URL, but it's just the slug (no scheme or hostname).
I may have misconfigured something though so wouldn't mind being advised if I have :)
Otherwise I love this, and have switched back to Yoast so I can use it :)