Is it possible to use JavaScript to change the meta-tags of the page?

后端 未结 18 1174
后悔当初
后悔当初 2020-11-22 14:14

If I put a div in the head and display:none, than use JavaScript to display it, will this work?

Edit:

I have stuff loaded in AJAX. And as my AJAX changes the

18条回答
  •  情书的邮戳
    2020-11-22 14:22

    You can change meta with, for example, jQuery calls, like this ones:

    $('meta[name=keywords]').attr('content', new_keywords);
    $('meta[name=description]').attr('content', new_description);
    

    I think it does matter for now, since google said that they will index ajax content via #!hashes and _escaped_fragment_ calls. And now they can verify it (even automatically, with headless browsers, see the 'Creating HTML Snapshots' link on the page mentioned above), so I think it is the way for hardcore SEO guys.

提交回复
热议问题