How to noindex ajax-loaded pages without a head tag?

by jacey.lubowitz , in category: SEO , 4 months ago

How to noindex ajax-loaded pages without a head tag?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer


by virginie , 4 months ago


If you want to noindex Ajax-loaded pages without a head tag, you can use JavaScript to dynamically update the meta tags when the page is loaded. Here's a step-by-step guide:

  1. Identify the section of your code where the Ajax content is loaded. This is typically done using an XMLHttpRequest or a framework like jQuery.
  2. Once you identify the section, you can add JavaScript code to update the meta tags dynamically. For example, if you're using jQuery, you can use the .append() or .html() method to inject the meta tag into the head section. // Example code using jQuery $('head').append(''); If you're not using jQuery, you can use plain JavaScript to achieve the same result.
  3. Place this JavaScript code within your Ajax content loading function, so that it runs every time new content is loaded. function loadAjaxContent() { // Your Ajax content loading code here // Update meta tags $('head').append(''); }

By dynamically updating the meta tags, you can effectively instruct search engines not to index these Ajax-loaded pages. Remember to adapt the code according to your specific implementation and tools used.