Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Looking For The Best Way To Include Schema Markup

  • #6740
    Avatar photo[anonymous]

    Hello, I’m looking for the best way to include Schema Markup in a theme. Do you have an idea ?

    Specially, I am looking to include the recipe schema markup in the Taste or Technews theme

    Thank you in advance for your ideas

    #6753
    Avatar photo[anonymous]

    Hi @Andy! Not sure if this is what you mean, but is it similar to breadcrumbs? If so, I have a few web pages bookmarked on that topic that seem to mention schema:

    “Breadcrumb and multilanguage” – code snippet for index.hbs by @Bob, one of the devs: https://forum.getpublii.com/topic/breadcrumb-and-multilanguage/

    “Breadcrumbs for Publii” – similar as above but with CSS code snippet: https://cv.domagic.site/posts/breadcrumbs-for-publii

    “Folder Structure” – helper by @t79 to generate breadcrumbs</span>: https://forum.getpublii.com/topic/folder-structure/

    #6754
    Avatar photo[anonymous]

    Hello !

    Thanks for the feedback! Sorry if it’s not very clear. I’m looking to include this: https://developers.google.com/search/docs/advanced/structured-data/recipe

    JSON-LD code in the head tag for each article

    #6756
    Avatar photo[anonymous]

    The script doesn’t actually have to go into the document head. From the Google Developers page:

    JSON-LD* (Recommended)
    A JavaScript notation embedded in a script tag in the page head or body.

    If you need schema markup specific to each individual post you can edit the HTML in the WYSIWYG editor, (or, if using the Block editor do an HTML block), so that it appears at the end of each post.

    #6758
    Avatar photo[anonymous]

    For some reason, my reply didn’t send, so I’ll try again

    #6760
    Avatar photo[anonymous]

    Andy wrote:

    Hello !

    Thanks for the feedback! Sorry if it’s not very clear. I’m looking to include this: https://developers.google.com/search/docs/advanced/structured-data/recipe

    JSON-LD code in the head tag for each article

    Thanks for the clarification. I would try out what Chris mentioned and see if that works.

    Otherwise, if it must be in the <head>, I would go about it this way: https://gist.github.com/candidexmedia/6304251e0bc2baf7ee07565b4f6fac49

    Unfortunately, the Publii forum seems to have blocked my reply, so I made a gist with the code snippets and instructions.

    #6770
    Avatar photo[anonymous]

    Thank you both for your answers.

    @chris :

    OMG, I had never seen that you could put that in the body tag! It seems the easiest!

    How can I retrieve dynamic information?
    Publii tags don’t seem to work in HMTL code if I put this in HTML code of a post

    #11770
    Avatar photo[anonymous]

    Discussion continued on the new forum: https://github.com/GetPublii/Publii/discussions/1400