Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Only my main page shows up on a Google search on site:domain.com and I start to wonder why this happens. I also use Google Webmaster Tools which confirms this.

On my main page, I have these types of links

<a href="1234/some-nice-seo-text" onclick="loadPageWithAjax(1234); return false;">

The 1234 is the id of the page to load and the '/some-nice-seo-text'-appended is just a good description of the content of the page, which I hope the Google-bot will catch. The intended user will click the link and the same content will dynamically be loaded and shown. It seems like the Google-bot never follows these links - am I doing something wrong?

share|improve this question
1  
It appears so. Test using Fetch as Google in the Webmaster Tools. –  closetnoc Mar 13 at 18:57
    
That tool was very helpful to me –  Kent Munthe Caspersen Mar 14 at 18:21
    
Good. I thought it would be. Glad to help. –  closetnoc Mar 14 at 18:25

2 Answers 2

up vote 0 down vote accepted

You are using path relative URLs in your href attribute. The problem is that the actual link destination depends on the page where the link is.

An example:

<a href="testlink">Testlink</a>

When the link is at http://www.example.com, the link will be expanded to http://www.example.com/testlink.

However, when the link is at http://www.example.com/subpage, the link will be expanded to http://www.example.com/subpage/testlink.

In general, it is really easy to shoot oneself in the foot by using path relative URLs in links. By using / in the start of href attribute, you ensure that all URLs are domain relative.

Does Webmaster tools show any crawl errors?

You should also test your page links by right-clicking on the link on your page, copying link location and then browsing to that page in another window. This way you can see if the links work right.

share|improve this answer
    
Thanks, this seems to be a common practice i missed! –  Kent Munthe Caspersen Mar 14 at 18:17

I had a rewrite in my .htaccess file to change http://www.domain.com to http://domain.com. After changing the rewrite to work in the opposite way, that is, rewrite from http://domain.com to http://www.domain.com, it finally worked. I confirmed this using the Fetch as Google tool.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.