#SEO question
26 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
What are you looking for out of the SEO config? The same og configs for all pages (and where? your frontend?)
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
Do every page have the same OG configs?
oh you mean the SEO plugin
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?
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
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?
where exactly does the metadata come from?
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?
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
Here's there generateMeta function in the example: https://github.com/payloadcms/payload/blob/main/templates/website/src/utilities/generateMeta.ts
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??
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
The function generateMetadata in example above had all answers for your questions. That exactly normal example you need.
You don't need to answer if you don't understand what they're asking.
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. 🤔
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
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
I hope you will make a remark not only to me, because as you can see from our correspondence, it was the previous author who started making fun of me. You made a remark to me, but not to him, is this discrimination? I am trying to protect myself from rude behavior, that's all.