Google+ Snippet with open schedule

I have a webpage that is dynamically built and I’m trying to get links that are available on Google+ to show fragments and look beautiful. An example of a snippet for rendering articles and documentation can be found here:

https://developers.google.com/+/web/snippet/article-rendering

When I follow the documentation, my links do not display everything that I installed in google plus, they are displayed as follows:

enter image description here

The head of my page looks like this:

<head> <div id="replaceGoogle"></div> </head> 

In my javascript, I have this to insert open graph tags after generation:

 //replace google var google = '<meta property="og:type" content="article" /><meta itemprop="og:headline" content="'+ data[0].name+'" /> <meta itemprop="og:description" content="View beer on Beer Portfolio" /> <meta property="og:image" content="'+ data[0].icon +'" />'; $("#replaceGoogle").replaceWith(google); 

Data is taken from json read from ajax call. Can't I do it dynamically?

+6
source share
2 answers

I think this question is similar to dynamically generating Open Graph meta tags . The main reason for your problem is that google + and facebook will not execute your javascript, so none of them will see your dynamic og tags.

Basic solution to this problem:

  • Create a unique URL for each dynamic page and save the dynamic parameters for that URL in the database.
  • when a user tries to share pages with this unique URL, you will find the saved dynamic settings
  • create a page with og tags filled with found dynamic parameters

Simple scheme for saving og tags for dynamically generated pages

+4
source

Use server side scripts (request details in the comments)

+1
source

All Articles