#SEO question

26 messages · Page 1 of 1 (latest)

modest dirge
#

Is it true that you can configure SEO directly in the payload.config, instead of specifying the meta in each schema?

Please share your experience.

fair ibexBOT
prime ivy
#

What are you looking for out of the SEO config? The same og configs for all pages (and where? your frontend?)

modest dirge
#

Next + Payload, I need to see how it will look in the home page. How I can generate it for every page not to adding in every schema

prime ivy
#

Do every page have the same OG configs?

modest dirge
#

no

#

they have different titles. descriptions and etc

prime ivy
#

oh you mean the SEO plugin

modest dirge
#

I've already seen this information, but I'm confused by the basic usage of the plugin, its usage in the component is not shown, and it's not shown how to get this metadata using it, that's the problem.

That's why I'm asking if anyone has an example of using and getting metadata using only the default settings, or is it still necessary to write the SEO to each schema?

prime ivy
#
      generateTitle: ({ doc }) => `Website.com — ${doc.title}`,
      generateDescription: ({ doc }) => doc.excerpt

doc is the document in question, the fields are what is available on the collection config

modest dirge
#

You can hardly help me, you don't understand what I'm talking about.

#

I already have basic settings, show me how to fetch metadata on inside my page?

prime ivy
#

where exactly does the metadata come from?

modest dirge
#

In the sense of where? I fill them in the CMS, but how do I get them from there so that they are displayed on the site?
How to generate them for all pages?

junior remnant
#

If I understand you correctly, you're looking to get the metadata rendered on your frontend. It looks like you have it all set up properly in Payload. So, you'll need to use NextJS to get it on your frontend using the generateMetadata function: https://nextjs.org/docs/app/building-your-application/optimizing/metadata – there's an option for dynamic metadata: https://nextjs.org/docs/app/building-your-application/optimizing/metadata. The official website template does a good example of showing this in action: https://github.com/payloadcms/payload/blob/main/templates/website/src/app/(frontend)/posts/[slug]/page.tsx

Use the Metadata API to define metadata in any layout or page.

GitHub

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for buildi...

modest dirge
# junior remnant If I understand you correctly, you're looking to get the metadata rendered on yo...

So the question is how do I get this data from the database?

When using this method,
https://github.com/payloadcms/payload/blob/main/templates/website/src/utilities/generateMeta.ts
you will have to specify the settings for the SEO in each scheme because everything will need to be typed, and my question was whether it is possible to get by with just the basic settings, and if not, then what is the point of them at all?

And if so, why is there no normal example in the documentation, and nowhere in the components is it shown how to get metadata. It's good that we can use the settings that Next offers us, but then what's the point of the settings that the payload offers??

GitHub

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for buildi...

prime ivy
#

If you can guarantee that all of your entities that need SEO have exactly the same fields where the metadata comes from, you can ignore the type warnings and just do doc.theFieldThatAllEntitiesHave

fierce thunder
modest dirge
fierce thunder
#

Ok 🤣

But,
"how do I get them from there so that they are displayed on the site?"
The SEO data come from queryPostBySlug function.

You keep asking how to get them back, but its right there. I don't know which is more "normal" than that example above. 🤔

modest dirge
#

Ask the question from the very beginning, where I explain what the point is. About the basic settings and settings due to adding the SEO to each of the schemes. I understand perfectly well how to get data from the SEO when it is added to the scheme, but I do not understand the basic settings, the use and receipt of which from the CMS database is not shown in any of the components.
I say, if you do not understand what the point is, then it is better not to answer.

Another inappropriate message and you will be blocked

opal pewter
#

Hey @modest dirge,

I assure you this is not the appropriate way to communicate with community members. Everyone here is trying to help you. I hope you reconsider the manner in which you interact with this community in the future.

The answer to your question has already been posted here and explained. You're using the SEO plugin which adds a few fields to every doc you've configured in the plugin config via the collections property. For example your pages. These pages get a meta group field with a few other fields added such as a title and description. After you save the doc in your CMS, you can retrieve this particular data directly through the doc you fetch from the API's. That is exactly what this function does: https://github.com/payloadcms/payload/blob/main/templates/website/src/utilities/generateMeta.ts#L29 It's used here: https://github.com/payloadcms/payload/blob/main/templates/website/src/app/(frontend)/[slug]/page.tsx#L84

It fetches the doc and reads the meta.title, meta.image (ogImage) and meta.description that you've added via the CMS. That's it. You can get by with just the "basic settings". The examples are shown for you in the website template already.

#

Thanks for all your help guys @junior remnant @prime ivy @fierce thunder

modest dirge