The 12 Best SEO Tips For Your Ruby on Rails App

Denny Jovic
Broadlume Product Development
10 min readJan 9, 2020

When doing any sort of research on how to improve your site’s SEO, I bet you came across endless articles talking about how to improve your WordPress blog. In these articles they say, “Use this widget” or “Install this plugin”, which isn’t very helpful or relevant to our skillset or to our non-WordPress projects. So I decided to cater the SEO experience to Ruby on Rails engineers.

For the purposes of this discussion we are going to focus on Organic Traffic only, because this is something that we can control in the code. Social traffic takes a lot of effort due to maintaining engagement and creating an audience, which I personally don’t have time for. Creating backlinks also takes time, and backlinks will come organically if you build an awesome site with organic traffic in mind.

In this article, I will be speaking about my personal site NFL Mock Draft Database because all of the things listed were executed to help it become one of the leaders this this niche market. For some context on its success, I created my first PR on February 3rd, 2019, launched it to production a month later and now today, on January 9th, 2020, the site is at the top of page 2 for my target keyword (which is fairly competitive). I currently average about 1.0k-1.5k users a day and 8–10k page views and those numbers are steadily climbing everyday.

So you have a cool idea for a site, awesome! Before you touch a single line of code, lets go through the 12 best SEO tips together.

1. Target A Keyword

This is the most important thing when it comes to organic traffic. You need to establish what you are going after. Now it doesn’t have to be a single word like “Football” it can be a phrase like “NFL Mock Draft”, which was the target for my site. Everything you do should be built around this keyword to help drive people that search for that keyword to your site.

You’re going to want to pick a keyword that has the following…

1 - A large volume of people searching for it.

2 - It isn’t too general like “Food” where its going to be next to impossible for you to rank for it.

3 - A keyword that has some variation or wiggle room to it so that when people search for something that is close to your keyword, they still find you.

4 - A site that isn’t too broad that it covers literally every topic known in existence. Keep it focused.

Below is an example of the different keywords that got people to my site in the past 3 months.

Variations on they keyword “NFL Mock Draft”

You’ll see all the different combinations of my target keyword, as well as different years showing up. People search for all kinds of things, so make it easy for them to find your site.

If you’re having trouble finding a good keyword, I like to use Google Trends. It’s free and it’ll give you an idea of what people are searching for today and historically. The more specific your keyword, the less volume of traffic there is but the less competitive it will be, so keep that in mind when you see these numbers.

2. Choose An SEO Friendly Domain

So this is tough one, and it sort of a game you play when finding the domain. Generally you’re going to want to keep to “.com” urls. I don’t know if this has any factor in SEO, but theres a reason those are always scooped up first. It could be familiarity or just a general public bias toward “.com” URLs being a more authority in your niche market. Whatever the case, try to get a “.com”.

So, cool, I know my target keyword is “NFL Mock Draft”, so let’s find out if nflmockdraft.com is available? Of course it isn’t, don’t be crazy, and this is not surprising. Most of the domains for your target keyword will be taken already, so it’s time to get creative. I head on over to Google Trends, type in my keyword, and voila, I see some other keywords to use.

Use Google Trends to find more keywords

Looking at the list, I see I could potentially use “Latest”, “Simulator”, “Database”, or “Updated” in my domain name.

Now I had done some raw google searches for my keyword and I came across a theme with other sites. These sites, which eventually became competition for my keyword, had pages labeled as “Mock Draft Database”. So my brain thought, “if they all these sites have pages named the same thing, then people are probably searching for it too!” So was mockdraftdatabase.com available? Nope, $%^%^@!!!! Ok, so I eventually settled on www.nflmockdraftdatabase.com, which wasn’t ideal but it was focused. It now kept my content centered squarely on the NFL, and NFL Mock Drafts.

Excellent, I had my keyword, and I had my domain. NOW it was time to start coding!

3. Pay Attention To Your URL Structure

Your typical rails app has you using IDs or GUIDs in your URL to find records in your database. I suggest you scrap this entirely and go for a Slug-based approach. By doing a Slug, you can control what is in the url, and you can make it read like english with content rich keywords.

An example of a URL using slugs

So my Mock model has a column called slug and in the file I have a before_validation callback that creates the slug for me called slugify. Other columns you’ll see are name, author_name, and year , which are all used in the slug.

class Mock < ApplicationRecord  
before_validation :slugify
private def slugify
slug = name.dup
author = author_name.try(:dup)
self.slug = [slug.remove("'").parameterize, year, author.try(:parameterize)].compact.join('-')
end
end

Though there isn’t a validation on this model to protect against it being unique, I know this slug will be. I am the one controlling the content, not the users, so I’m actually ok with pages being overridden if the slug is the same. Each Mock is unique per year, author, and name (or site).

4. Maintain Rich Content

I built this site without users and I’m not a writer, so content was the hardest part. It is essential, and you aren’t going to get by with little sentences here and there describing your business. You need large chunks of content rich text to help boost your SEO traffic. Articles generally perform the best because all they are is content rich text.

If you see a section that has one sentence that can be expended upon, do it! I personally wouldn’t worry so much about the aesthetics of it, and/or will people read it. For the most part, that content is for google to crawl and if the reader wants to read it they most certainly can.

I guess a key thing here is, if you find yourself writing more code than text on the page, thats probably a bad sign. Write anything and everything to help support your keyword.

I created rich content by giving each list item its own description

5. Speed Is Key

Generally speaking we all like fast loading sites. We don’t want to wait that half second for stuff to load, because we are impatient animals that need content NOW!!

I took this concept to another level and made speed a priority in my app. The main thing I did was dump all relevant content to a single json column on each Mock called data . This basically eliminated the need for using ActiveRecord in the controller/views, so all I needed to do was go into the data for a single item in the list and display what’s inside.

An example of whats inside my JSON data

Naturally, everything loads fast as a result. The 2nd thing I did to improve speed was to optimize images in general. Try your best to use svg formatted images, and if you can’t, there are plenty of converters out there that can do this for you. This one was my favorites because it keeps your colors intact during conversion.

However I still wasn’t happy with the images load times. I implemented a LazyLoad script that would load a default image first to unblock the rest of your content to load, then load your actual images asynchronous. This way only 1 or 2 images have to load before the content instead of 50 or so.

Before (left) and After (right)

Though my app doesn’t adhere to the best rails practices (ie using ActiveRecord on the backend to store into a single json column), it serves its purpose for a fun side project app I made.

6. Title Tag

Every site needs and has one, this we know. What you probably didn’t know is that Google doesn’t really care how long it is. In fact if you want to make it longer, those terms are used in the Google algorithm for ranking your site.

The problem lies with what the user sees when they search for your site.

Option A: Long title that gets clipped
Option B: No extra fluff, just the name of the site

What do you like better? Which do you feel more confident clicking on? This is different for everyone and is a personal preference. However if you are indifferent, I suggest you lean toward something like Option A.

7. Description Tag

This is another opportunity to get your keyword in with a nice readable paragraph that will entice people to click on your site.

Not much to say about this, just make sure you have it. If you get stumped, what I like to do is research my competitors and see what they wrote. Obviously don’t copy and paste the same thing, but script your own version of it, because you’re competing for the same keywords.

8. H1 Tag

Here I used my programmer hat and got creative with the H1 tag for every page. Its hidden in plain site on the nav-bar.

My Logo is my H1 tag

On every page you visit, my H1 tag is NFL Mock Draft Database , and I used CSS to make the H1 tag look like an image. The H1 tag is another way that google crawls your site to see if your content is relevant for a searched keyword, so make sure it supports your target keyword.

9. Time Tag

Something I never knew until I created this app, was the idea of a time tag and what its purpose serves.

<time datetime="#{time}">"Last Updated: #{time_ago_in_words(time)}"</time>
1 day ago my site was updated

I think this is more important for pages that publish articles frequently, however it doesn’t hurt to have it.

10. Well Placed Internal Links

My entire site is ripe with internal links, but one mistake I made was relying heavily on people using the nav bar to go through the site. Before I made the change below, I was getting about 2–3 page views per user. Now I get closer to 6 per user, by adding one thing.

Two big buttons (PREV & NEXT) that let the user go back and forward through my pages

This simple addition created so much engagement that now my users are spending, on average, almost 3 minutes per session on my site.

Though external links, or referrals, are better for your SEO, internal links play a big part too. So try to keep your users engaged by adding more content the users can go to. Make it easy for them to stay on your site.

11. The Faults of Endless Scroll

When I first created the site, I implemented endless scroll and I loved it. It was clean, easy to use, and users liked it too. Do you know who didn’t? Google. To Google, your content ends on page 1, and you literally have no more content, which obviously isn’t true. So for Google to know you have more content, just add pagination with clickable links.

I used the gem will_paginate

Yes it’s a knock to the user experience, but the rewards far outweigh the negatives. Another bonus with clickable links is that now page 6, for example, can be linked out to other people. With endless scroll that wouldve been impossible.

12. Sitemaps

Lastly, make sure you have a sitemap. Now the best part is, sitemaps are super easy to do. What I did was create a sitemap_controller with an index endpoint and view, and treat it like any other endpoint in your app.

In my case, I looped over all my Mock entries in the index.html.erb file and did the following…

No need to type every page individually!

And then in the routes file I did

get '/sitemap.xml', to: 'sitemap#index'

Well there it is. The magic behind a few SEO tricks that cater to you, the rails engineer. Good luck on venturing into the deep spaces of Google, and I promise you if you implement some of these tricks, you’ll be better off for it. I know it worked for my site NFL Mock Draft Database.

Hi there, I’m Denny and I’m currently a Software Engineer at AdHawk. We are working on a variety of exciting new technologies and applications and are always looking for talented engineers to join our fast-growing team. Take a look at our job board and apply today -> https://www.tryadhawk.com/jobs/

--

--