I got some variables ing from php to fit in the meta tags of facebook. So I need to append these tags to head with js. I´m doing the following:
<script>
$(document).ready(function(){
console.log("ready");
$("head").append('<meta property="og:title" content="<?php echo $title; ?>"/><meta property="og:type" content="website"/><meta property="og:image" content="/<?php echo $pic ?>"/><meta property="og:description" content="Weitere Events und Bilder auf www.party-news.de"/>');
});
</script>
I see it in debugger but not in "source code view". Also Facebook does not recognize the new generated meta tags. (these tags work if I place them statically).
Could someone help?
I got some variables ing from php to fit in the meta tags of facebook. So I need to append these tags to head with js. I´m doing the following:
<script>
$(document).ready(function(){
console.log("ready");
$("head").append('<meta property="og:title" content="<?php echo $title; ?>"/><meta property="og:type" content="website"/><meta property="og:image" content="http://www.party-news.de/party/images/termine/flyer/<?php echo $pic ?>"/><meta property="og:description" content="Weitere Events und Bilder auf www.party-news.de"/>');
});
</script>
I see it in debugger but not in "source code view". Also Facebook does not recognize the new generated meta tags. (these tags work if I place them statically).
Could someone help?
Share Improve this question asked Sep 10, 2015 at 15:55 m1crdym1crdy 1,4012 gold badges26 silver badges60 bronze badges 1- Things you add dynamically won't show up in normal "source code views". Also I don't know if whatever facebook crawls your page with executes js. – m02ph3u5 Commented Sep 10, 2015 at 15:58
1 Answer
Reset to default 6The FB crawler doesn't execute Javascript, so this won't work. See
- https://developers.facebook./docs/sharing/webmasters/crawler
- https://developers.facebook./docs/sharing/best-practices
You should have a look at tools like https://prerender.io/ which can statically render dynamic sites.