sanity-io / sanity-plugin-seo-pane

Run Yoast's SEO review tools using Sanity data, inside a List View Pane.
MIT License
38 stars 8 forks source link

Error: No canonical URL found using Next13 metadata export #24

Open modulareverything opened 1 year ago

modulareverything commented 1 year ago

Hey, in my layout.jsx file I'm setting the canonical URL like so:

export const metadata = {
  title: "testing",
  metadataBase: new URL("http://localhost:3000"),
  alternates: {
    canonical: "/",
  },
};

I can see this is adding correctly into the head on my code, but when testing the SEO plugin locally (http://localhost:3000/admin for me), I get Error: No canonical URL found

Is this a bug or am I doing something wrong?

graemec23 commented 6 months ago

@modulareverything Im getting this same bug, I can see the canonical url in the code but am getting the same error in Sanity. Were you able to resolve it?

modulareverything commented 6 months ago

I don't think I ever actually fixed this to be honest, and just ended up not using this plugin as it was just for a test. Sorry it's not very helpful.

eddiewilson commented 6 months ago

@modulareverything - Is localhost:3000 your development port. I had the same error with a Gatsby project on localhost:8000. Ran a local production build on localhost:9000 and used this as the production url for the options.url for Seo-pane. Allowed me to get beyond this.

graemec23 commented 6 months ago

@eddiewilson I made sure when I tried it that I pointed it a production url of the site, rather than locally. Its strange.

waynedunkley commented 6 months ago

In my case the reason no canonical data was found when pointing to localhost rather than production was that the page was not pre-rendered and the response from the preview URL was in javascript rather than a HTML string response. This is discussed here: https://www.sanity.io/plugins/seo-pane#rendering-preview-content-server-side You'll need to update your preview query to return HTML.