title: "Single-page" JS websites and SEO
body: <p>There are a lot of cool tools for making powerful "single-page" JavaScript websites nowadays. In my opinion, this is done right by letting the server act as an API (and nothing more) and letting the client handle all of the HTML generation stuff. The problem with this "pattern" is the lack of search engine support. I can think of two solutions:</p>
  
  <ol>
  <li>When the user enters the website, let the server render the page exactly as the client would upon navigation. So if I go to <code>http://example.com/my_path</code> directly the server would render the same thing as the client would if I go to <code>/my_path</code> through pushState.</li>
  <li>Let the server provide a special website only for the search engine bots. If a normal user visits <code>http://example.com/my_path</code> the server should give him a JavaScript heavy version of the website. But if the Google bot visits, the server should give it some minimal HTML with the content I want Google to index.</li>
  </ol>
  
  <p>The first solution is discussed further <a href="https://stackoverflow.com/questions/6193858/pushstate-and-seo">here</a>. I have been working on a website doing this and it's not a very nice experience. It's not DRY and in my case I had to use two different template engines for the client and the server.</p>
  
  <p>I think I have seen the second solution for some good ol' Flash websites. I like this approach much more than the first one and with the right tool on the server it could be done  quite painlessly.</p>
  
  <p>So what I'm really wondering is the following:</p>
  
  <ul>
  <li>Can you think of any better solution?</li>
  <li>What are the disadvantages with the second solution? If Google in some way finds out that I'm not serving the exact same content for the Google bot as a regular user, would I then be punished in the search results?</li>
  </ul>