Google's SEO Starter Guide Part I
Before I get into the article, I first like to thank Andrés Álvarez for his blog https://aalvarez.me/. He has some very useful Middleman articles. I use his blog post for creating my first Middleman helper.
So I want to improve the sites rankings and to do this I am going to be working through the documentation Google provides starting with their Search Engine Optimization (SEO) Starter Guide.
Let's define a benchmark so that I can look back and see if the changes I make do anything to improve the ranking. The values from the previous article are true on the day of writing, which is 25 March 2020, with the exception of an increase in the number of valid pages.
|Date||Total Impressions||Total Clicks||Average Position||Valid Pages||Pages in Error||Valid Mobile Pages||Mobile Pages in Error|
|16 March 2020||1||0||0||174||31||0||2|
Create unique, accurate page titles
"You should create a unique title for each page on your site."
"Accurately describe the page's content"
A quick check and even at the very top level I have got this wrong. The home page and the blog page share the same Title. Blog article pages already have the title of article included but I will also add an additional prefix of 'Blog'. I had to make the
<title> tag a little smarter. My config.erb originally had the
<title> defined as
... <title>A Website From Scratch<%= ' - ' + current_article.title unless current_article.nil? %></title> ...
I replaced this with
... <% if defined?(current_article.title) %> <title><%='A Website From Scratch - Blog: ' + current_article.title %></title> <% elsif defined?(current_page.data.title) %> <title><%='A Website From Scratch - ' + current_page.data.title %></title> <% elsif current_page.url.include? "/blog/tags/" %> <title><%='A Website From Scratch - Tags: ' + current_page.url.split("/") %></title> <% else %> <title>A Website From Scratch</title> <% end %> ...
In the original version when I found an article title I would append this to the end of 'A Website From Scratch' giving me the unique title for each article. This logic is maintained by the first
if statement but with the 'Blog' prefix. The first
elseif statement looks for a page title and if this is found it appends it onto the 'A Website From Scratch' string. In order for this statement to work it required me to add a frontmatter title key to my archive, blog, tutorials and calendar templates. The second
elseif is required to make the top level tag pages unique. You can't access the tagname that is used by the tag.html.erb file that comes with the Middleman blogging plugin. Instead the
current_page.url variable is used to identify that we are dealing with a tags page and then split this on a '/' so that we can get the Tag.
Use the "description" meta tag
"Accurately summarize the page content"
"Use unique descriptions for each page"
"Avoid using a single description meta tag across all of your site's pages or a large group of pages."
I currently have a single description in my layout.erb
... <meta name="description" content="Meta Blogging - A blog about how this site was built and all the steps, tools and sources involved"> ...
This will need to change to be dynamic. All the articles have a description but they probably need to be improved so I will have to go back and rework them. I will need to add unique descriptions for the top level pages in the same way I did the page title.
My new description meta tag is
... <% if defined?(current_article.data.description) %> <%='<meta name="description" content="' + current_article.data.description + '">' %> <% elsif defined?(current_page.data.top_description) %> <%='<meta name="description" content="' + current_page.data.top_description + '">' %> <% elsif current_page.url.include? "/blog/tags/" %> <%='<meta name="description" content="Blog articles that have the tag ' + current_page.url.split("/") + '">' %> <% else %> <meta name="description" content="This site is built using Middleman with a backend built using Terraform and hosted in AWS. I have tried to document everything that has been done to build it both what worked and what didn't."> <% end %> ...
In the same way as titles the blog posts are taken care of, the top_description frontmatter is used for all other pages but the home and for tags. Again we use the current pages URL data for tags and the final catch all for the home and anything I might have missed.
The changes discussed in this article have been applied on the 29 March 2020.