Update Meta Title & Description using Javascript / Jquery

The script below will update meta title dynamically - don’t think it changes it for SEO purposes as (please correct me if I’m wrong) Google crawls the sites content before this Javascript is executed.

I needed it for display purposes and it works - passing the UPDATED META TITLE and UPDATED DESCRIPTION from a collection list on the page.

     $('head title').text("UPDATED META TITLE");
     $('head').append( '<meta name="description" content="UPDATED DESCRIPTION">' );

Changing your meta content in “runtime” is probably not considered by search engines, however they do analyse JS and penalize “sneaky” and obfuscating behavior. Altering the title, sure why not! Why do you need to change the description though?

So, your question is how you get the data from the cms dynamically into your jquery functions?

Yep - i thought so.

I just updated the meta description just incase a user somehow found it - and also just to learn how to do it.

I don’t have a question - was just posting this bit of code in case it came in handy for someone else.

Okay :grinning:
Just to be sure, after reloading the page the meta contents will revert to the ones set in Webflow!

Yep, it’s purely for display purposes!


1 Like