artiebits / svelte-seo

Optimize your website for search engines and social media with meta tags, Open Graph, and JSON-LD.
https://artiebits.com
MIT License
446 stars 24 forks source link

Layout wont get overwritten by Page, but appends. #78

Closed ohbob closed 6 months ago

ohbob commented 9 months ago

Describe the bug Layout seo data doesn't get overwritten by page. It stacks on top, but on e.g facebook, we see the the data from layout, not the page.

To Reproduce Steps to reproduce the behavior:

  1. Add sample SEO data in layout.
  2. Add sample SEO data in page.
  3. See the contents of page,
  4. See error - data from layout hasn't been overwritten by page.

Expected behavior I would expect that the layout gets overwritten by page Seo Data.

Additional context If this is the intended way, then explain on how you imagine to use the plugin?

lubiah commented 9 months ago

Even though the data from the page is appended, when the browser is loading the page, it only takes into account the last tags so it would use those of the page instead of the layout

ohbob commented 9 months ago

try facebook and twitter preview and you will see that its not the case, one of them handles them right, the other doesn't. it's a big deal.

lubiah commented 8 months ago

Then inside the layout, try getting the page data from there

ohbob commented 8 months ago

Then inside the layout, try getting the page data from there

I'm not really following on how i can do that. An example would be appreciated.

lubiah commented 8 months ago

Sorry, I'm kinda busy but try this.

Return the SEO data from a load function inside the page.

Then inside layout, Try to access it like this

<script>
  import { page } from '$app/stores';
  import Head from 'svelte-seo'
</script>
<Head  facebook={{$page.data.seo.facebook}}/>
github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lubiah commented 6 months ago

I'm yet to look into this issue