Change Meta Tags dynamically Angularjs

Asked

Viewed 98 times

2

I’m trying to change the content meta tag Keyword dynamically. Have:

<meta name="keywords" id="selKeyword" content="">

and I’m performing as follows:

$("meta[name='keywords']").attr("content", "hello");

I put a display in the Keywords meta and saw that hello was set, but when I go to display source I see that the content is still blank.

Is there any way around this problem?

EDIT: I didn’t have to do this in my project anymore, but in none of the answers I was able to do the solution. I don’t need it anymore. Thank you to everyone who helped me

  • I don’t know exactly the goal, but if it’s for indexing, it doesn’t do much to change the meta tags with JS. By the time the JS has changed, the bots will have read the previous values and "gone". In fact, what happens is that the JS will touch the DOM, not the original document.

  • So, I even saw some people talking about it already, but unfortunately I’m an employee and the boss wants it hehehe.

  • @Pizzanio your problem is the boss, not the technology.

  • heheheh... well that, but I managed to convince him how unnecessary it is.

  • @Pizzanio I understand the need, but it is not in Angular that the solution resides.

1 answer

0

The only Crawler that interprets JS before capturing tags meta is the one from Google - and yet there is no guarantee that your javascript content will run.

One output can be the interpretation of the content server-side before the browser issue, however the implementation will depend on your server platform.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.