About the Server Actions library and data transfer.
Create a Server Action in the library and create a table (or create a variable).
Create a Server Action and call the library Server Action from there. If you don’t assign a name, the data won’t be transferred. If a name is assigned in the exec, the data will be visible in the branch with that name.
Now I call the library Server Action in Globals. And I assign the name “seoo”.
Next, when configuring the SEO tags in main.ejs, I will see “seoo” simply as a variable, but I will also see what is created in the library Server Action. I have highlighted this in red.
However, the data does not appear in the tag this way. Neither using the path global_seo_query.description nor using the path seoo.global_seo_query.description. It turns out that data created in library Server Actions is not accessible on the website page.
If I move the data from the library Server Action to Globals, everything works.
I’m creating SEO tags on the page. Previously, I retrieved a table from the database for this purpose. This was done in globals.json. In the SEO tags on the page, I specified the path to this data as global_seo_query.description, etc. Everything worked fine.
Now I tried moving the database query to the Server Actions library and calling this server action in globals.json. And now the data isn’t available on the page.
Exec only outputs data, while Include allows you to pick data from within the action. Please check the article above, it explains how and when to use both.
Thank you very much. I didn't know about “include”.
However, in your example, when using “exec”, the data is displayed in the “exec” section when the API is called in the browser. In other words, the data is transmitted to the parent server action. But there's no way to access it on the page, right?
Thanks for the link. It doesn't answer my question, but since using “include” instead of “exec” solves my problem for now, let's leave it at that.
However, the link discusses a topic that’s relevant to me. Is it possible to create custom meta tags? I need meta tags that point to the website’s versions in different languages in the following format:
I'm adding this to the layout page. If it's placed in the header section, everything works and the tags appear. However, if I move it to the head section (where it's supposed to be), it no longer works.
Yes, of course it's possible.
All you need to do is make sure the app root is set to page, not to body, so this way the dynamic data in the head tags is rendered:
Best practice is to render your SEO server side otherwise you will see unrendered expressions appear in search results snippets. Then specify the server side data Action in the Layout page and select your meta values from it.
Otherwise you could end up with (displaying in Google etc):