0

I got a question, its possible to change the Metatag Keywords with JQuery?

I Already tried this but didn't work.

$("meta").attr("description", "Keywords bla bla bla");

And this

$('meta[name=keywords]').attr('content', 'New Author Name');

Any solution?

Felipe Leñero
  • 55
  • 2
  • 12
  • 1
    meta tags are used as static content by, for example: google, search engines primarily, and are used to know some words that you think are important for indexing the given site. You need to do this on the server. – jcolebrand Jun 06 '12 at 19:48
  • 'Cause its a CMS and i want to manage the Dynamic Content – Felipe Leñero Jun 06 '12 at 19:49
  • 1
    @FelipeLeñero: But meta tags aren't read by the browser, they're read by search engines. Using JavaScript to change them doesn't do anything, and serves no purpose. – gen_Eric Jun 06 '12 at 19:50
  • Your second example should work, but it's pointless since META tags are used when the page loads and your editing the tags after the load. – Zachary Jun 06 '12 at 19:50
  • Ohhh, well that explains everything. Thanks a lot! Regards! – Felipe Leñero Jun 06 '12 at 19:51
  • 1
    EVERYBODY REPEAT AFTER ME: META TAGS ARE STATIC CONTENT. JAVASCRIPT IS FOR DYNAMICS. – jcolebrand Jun 06 '12 at 19:52
  • 5
    @jcolebrand: "AFTER ME: META TAGS ARE STATIC CONTENT. JAVASCRIPT IS FOR DYNAMICS.". – gen_Eric Jun 06 '12 at 19:52
  • That's correct what @Rocket said. Crawlers wont be able to run js. Altho, there are some meta tags used by browsers. Like [iPhone scale and rotation](http://stackoverflow.com/questions/1230019/how-to-set-viewport-meta-for-iphone-that-handles-rotation-properly) – Vizualni Jun 06 '12 at 19:54
  • @Vizualni: True, though I'm not sure if anything would happen if you changed them with JavaScript. – gen_Eric Jun 06 '12 at 20:19

2 Answers2

4

The whole purpose of metatags is to help searchers. If you load them via JS searchers (spiders) wont read them, and there is no point in having them

Nicolás Torres
  • 1,385
  • 8
  • 13
0

I did experiment with this to psyche out Facebook's Open Graph, and turns out meta tags are loaded before JS, kind of mooting the entire idea.

Anna Billstrom
  • 2,482
  • 25
  • 33