-3

I know there are MANY questions that address SEO with single page websites/applications. However, I have a very specific question that I haven't seen directly asked.

I have a very simple static website with 4 pages. This is not a javascript intensive site or a single page application. The content and SEO is what really matters. It's so simple that I would like to load all of the website's content (all 4 pages) in one page, so that when the user clicks a link to go to another "page" there is no http request, ajax, or page loading. It just hides the current page's content, and show's the next page's content that is already loaded, and uses pushState to handle the url and history.

What this means is that when the search engine crawls www.mysite.com/about, at the top will be the content for the about page clearly visible, but somewhere on the page I would have to store the html for the other 3 pages without those 3 pages being indexed as part of the about page. So on any given page, I would have 3 other page's content somewhere, hidden.

A) Is this possible? B) Is this safe to do without search engines interpreting it as me trying to be misleading about the content i'm showing.

Edit: This questions is about single page websites and SEO, which both specifically require html, javascript, pushstate, and single page application methods

wired_in
  • 2,593
  • 3
  • 25
  • 32
  • 5
    This question appears to be off-topic because it is about SEO – John Conde Feb 14 '14 at 16:56
  • 1
    Yes it is about SEO, but the solution requires javascript, pushstate, html, and single page application methods. – wired_in Feb 14 '14 at 16:57
  • google and bing both execute JS on your page as they index it; do you care about any other engines? run the google webmaster tools on your site to check if there's an actual problem with what you have before you worry about boogeymen. – dandavis Feb 14 '14 at 18:27
  • @dandavis What does google and bing executing JS have to do with my question? I'm not going to re-iterate what is clearly asked in my question. Running web master tools isn't going to tell me exactly what google is going to index and what it isn't. – wired_in Feb 14 '14 at 18:39
  • it means they can find and index your hidden content if links display it. webmaster tools won't give away the secrets, but it will tell if something is FUBAR. – dandavis Feb 14 '14 at 18:42

1 Answers1

3

I don't think that is possible in the way you explained. It requires Ajax :

• 4 HTML pages (index.html, about.html, and so on)

• Ajax only load the content of each page, on demand, and you can handle URL with pushstate, so you can have a navigation that doesn't reload the browser

• Google can crawl each HTML page without JS consideration

Why your solution won't work ?

• Google will crawl the whole index page (regardless of which content should be displayed)

Note that I'm not SEO expert, just giving my point of view (technical :) ).

Without AJAX :

• Implement your content as JS variables or objects in an external JS file :

about = {
  title:"My page title",
  content:"My page content",
  url:"/about/"
};

• make your js file hidden from search engines :

User-agent: *
Disallow: /js/main.js

• make the calls to implement the new content whatever the page you click on :

$('nav a').click(function(){
  var href = $(this).attr('href'); // be sure the href of the a element has the same name as the JS object
  $('h1.title').text(href.title);
  $('p.content').text(href.content);
  history.replaceState(page: href.url,href.title,href.url);
});

Not sure the JS part will work as I didn't test it.

enguerranws
  • 8,087
  • 8
  • 49
  • 97
  • This is how I am currently implementing it. The site is so simple, the only reason I'm adding the overhead of using ajax is because of this problem. I would like to know if there is anyway to get rid of those unnecessary ajax calls. – wired_in Feb 14 '14 at 17:07
  • Also, yes each page when visited directly in the browser will be it's own page. – wired_in Feb 14 '14 at 17:08
  • The other solution, if you don't want Ajax calls, is to toggle content in the same page with some JS. But in this case, search engines won't care about it and crawl the whole file. – enguerranws Feb 14 '14 at 17:09
  • If I type www.mysite.com/about into the browser, it will load all 4 pages, but it will only show the content for "about", so it will appear to any human to be just the about page, but I need the search engine to know not to index the other 3 pages' hidden content – wired_in Feb 14 '14 at 17:10
  • So just only put "about" content in about page ? Just put the necessary content in each page. And if you need to load content from another page, do it with ajax. – enguerranws Feb 14 '14 at 17:11
  • That's my point... I want to know if there is some way that I don't know about to accomplish this, where I can store the other pages' content on the page out of sight and signal to the search engine not to index it as part of the current page – wired_in Feb 14 '14 at 17:11
  • That's the whole point of my question here... If I just put the about content on the about page, it would require ajax calls (more http requests) to load other pages. I don't want that. – wired_in Feb 14 '14 at 17:12
  • The way I told in my answer. Content of each page will be stored in each page. If the user clicks on about page, the ajax call will get about.html#content. – enguerranws Feb 14 '14 at 17:13
  • I DON'T WANT TO USE AJAX, I want the entire site to be loaded all in one request, and then just switch between content using javascript, so it will be instant – wired_in Feb 14 '14 at 17:14
  • 1
    Store all the content in JS objects in each pages ? Example : about.title = "About us"; about.content = "The content of that page". – enguerranws Feb 14 '14 at 17:15
  • Now that is very possible. I'll have to look into that. I was hoping someone had done this before and has a best practice / 100% proven solution. – wired_in Feb 14 '14 at 17:18
  • Don't wanna use JS objects too ? – enguerranws Feb 14 '14 at 17:19
  • I didn't say that, I said I need to look into it. You are just hypothesizing about what could work. I'm not sure that is 100% full proof or if it's the right way to go. – wired_in Feb 14 '14 at 17:21
  • https://developers.google.com/search-appliance/documentation/68/admin_crawl/AdvancedTopics#index_writein : I guess Google will crawl that content, as it's on the document. – enguerranws Feb 14 '14 at 17:26
  • So the best SEO friendly solution it still AJAX. What you wanna do is having some content on your page that Google won't crawl. I don't think it's possible. – enguerranws Feb 14 '14 at 17:28
  • According to that link, it only crawls content added by using document.write/writeIn which is content added while the page is loading. So it seems this could still work as long as the content is in a javascript object property, and is added to the page after page load, when a user clicks a link. – wired_in Feb 14 '14 at 17:31
  • 2
    The best way would be to store your content as variables or objects in your external JS file and make it unreadable by bots with a robots.txt. That's the way I would make it. – enguerranws Feb 14 '14 at 17:34
  • Your answer above explains how I currently have it implemented, and your first bullet point under "Why your solution won't work ?" is wrong. If you change the answer to reflect our discussion, I'll at least upvote it, and then accept it after trying it out. – wired_in Feb 14 '14 at 17:44
  • Yes, but the thing is : the thing you tried to do couldn't work, or wouldn't be SEO effective, as you wanted. – enguerranws Feb 14 '14 at 17:48
  • Ya it wouldn't work, but that first bullet point isn't a valid reason. Even though I'm using pushstate to "fake" the pages /about /resume, etc. My server also serves the correct page when you request /about /resume directly through the browser, so they aren't fake pages. – wired_in Feb 14 '14 at 17:50
  • If I type www.mysite.com/resume into the browser, it will serve all 4 page's content, with the resume content visible, and the other 3 hidden somehow, so the page does actually exist – wired_in Feb 14 '14 at 17:51
  • Sure, I missed that point. – enguerranws Feb 14 '14 at 17:52