Jump to content

dynamic itemprop URL for Schema Mircodata


BadCoder
 Share

Recommended Posts

This is my first post and I'm not very good with Java. I'm trying to automatically create the following schema meta tag for my website:

<meta itemprop="url" content="URLofthispage" />

The best I came up (pieced together from the internet) with is:

<script>var addLink = function(url){
  var link = document.createElement('meta');
  link.setAttribute('itemprop', 'url');
  link.content =  window.location.href;
  document.getElementsByID('placehere')[0].appendChild(link);
</script>

And then <p id="placehere"><p> to place the meta tag in the correct location in my code.

I have tried the same format also for <link itemprop="url" href="URLofthispage" /> which can also be used for the url tag.

Any suggestions would be greatly appreciated.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...