SEO Considerations on AppEngine

In moving to AppEngine I also put in a bit of effort to make my site more SEO friendly and searchable. Hopefully it helps. I detail some of it in this post.

Since my move to AppEngine yesterday, I was shocked and appalled that my site still gets the same pathetic amount of visitors, and that the number of visitors hasn't climbed exponentially after posting a link on Twitter AND Facebook. What's a guy gotta do?

Since I deal with websites in my day job, I've picked up on a few things that are good for SEO. And also applied some that I think might be a good idea.

Not necessarily related to SEO but now my links all raise events on analytics. I'm not sure how good or bad this is, but it's easy! And it'll help me feel like people are doing stuff on here.

Another thing I added was canonical URLs. I'm never really sure how to do these, particularly when it comes to paging querystring parameters. But I came up with an interesting solution. My page numbers now print in reverse! However, the list on the backend is not reversed. This post at the time of this writing will occupy the 0th index in my posts array.

You might as well see some code since I've been neck deep in it for a few days.

func applyPaging(pageIndex, pagesize int, posts []Post) []Post {
	if len(posts) < pagesize {
		return posts
	}

	pc := len(posts)
	mp := getPageCount(pc, pagesize)

	if pageIndex < 0 {
		pageIndex = mp
	}

	start := pageIndex * pagesize
	end := (pageIndex + 1) * pagesize

	if start > pc {
		start = pc
	}
	if end > pc {
		end = pc
	}

	start, end = pc-start, pc-end

	return posts[end:start]
}

If page -1 (the url without any paging parameters), then set the current page to the last page. Get standard paging start and end values. Start on pageIndex*pagesize  (page 0 is 0, page 3 is 45 with page size 15), and on the next page, 60 in this case. If any are larger than the amount of posts, set them to the amount of posts.

THEN!!!  Reverse the values. If 80 posts, page 3 start and end will be 35 and 20 instead of 45 to 60. Posts are in order by date, so with the values 35 and 20, I just want the posts 20 to 35.

In order, these posts are order by date so their indices are 0 (latest), 1 (second latest), 2, etc. Posts 20 to 35 represent 45 and 60 positions away from the right side.

What this accomplishes, is that I can use a canonical URL with the query string, and page 33 for example, will never change. If I'm adding posts to the front and having the front be page 0, every time a new post is added, all the pages will be different. So I couldn't really tell a search engine to index the page by a page index, it'd pretty much be guaranteed to be wrong.

On top of that I now kind of have meta descriptions, and page titles for tag and date searches. I will have to add the page number to the title as well. Now the only page that will change is the home page as I add new posts to it, but once those posts leave the home page, their page number will always be the same. That should help.

blog comments powered by Disqus