10

I am having a doubt regarding to this issue where let's say my page load is

<title>Test Only</title>

and I change the value by using javascript to

<title>Test Use JS Change</title>

// this is my Javascript code to update the <title> value after page load
$(function(){
    $('title').html('Test Use JS Change');
});

May I know for Search Engine Bot, will they recognize my title as Test Use JS Change or Test Only

It is because when I see the browser tab/ inspect element to view dynamic source, the title has been updated but when I purely view source only, it shows the default title that I defined.

Would need some advise regarding to this. Thanks!

Keith Yeoh
  • 591
  • 1
  • 6
  • 18
  • 2
    Bots see the title you put into your source code, not the one which is generated by JS. – pavel Jun 02 '15 at 06:07
  • @panther thank you for the reply, which mean it is pointless to change the metadata by using JS if I want the bot to crawl it. – Keith Yeoh Jun 02 '15 at 06:33
  • When you change title depending on event on your site (eg. click), it helps to users but bots don't click (they fire no JS events like click, mouseover, etc.). Change title after the page is load with no other action make no sense. – pavel Jun 02 '15 at 07:08

1 Answers1

25

You can use JavaScript. Some bots, including Google, will execute the JavaScript for the benefit of SEO (showing the correct title in the SERP).

document.title = "Google will run this JS and show the title in the search results!";

Articles showing positive results: http://www.aukseo.co.uk/use-javascript-to-generate-seo-friendly-title-tags-1275/ http://www.ifinity.com.au/2012/10/04/Changing_a_Page_Title_with_Javascript_to_update_a_Google_SERP_Entry

Don't always assume a bot won't execute JavaScript. http://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157

Google and other search engines know that the best results to index are the results that the actual end user will see in their browser, including JavaScript.

yazzer
  • 493
  • 5
  • 9