How to build dynamic open graph tags?

The best solution would be to bind a query with the relevant information for your tags as server-side data for the page:

Just add the meta tags and put the bindings inside - they will be rendered without the need for page JS