How to change a meta tag in a SPA?

Asked

Viewed 54 times

1

I have a SPA made with pure javascript, and I needed to change the meta Description after an event, for example, a click.

Using javascript I can change, but I believe that for Google’s Crawler it makes no difference.

That is correct?

Is there any other way to change the meta Description of a page that doesn’t have Reload? Something using hash?

  • 2

    It makes no sense to change a meta after the page served. If it is a SPA, it is a single page, if you want different indexing by "part" of the SPA, you need to handle the individually generated Urls (control the server-side meta depending on the URL accessed). Example: if the user accessed the SPA by http://application/way2, serves the goal of way2. If you go to http://application/way1, serve the goal of way1 (this is independent of whether you use the same page to serve the 2 paths)

  • 3

    In other words: it’s not that you need to change the goal after the click, but you need to change the goal when the URL generated by the click is accessed in the future. Crawlers who will use the meta will usually not navigate through your SPA by clicking the links, they will make individual requests (as if they were separate pages). So it’s good to know how to use the history API, and configure the server to handle Urls well by starting with specific SPA functions.

No answers

Browser other questions tagged

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