Skip to content
This repository was archived by the owner on Dec 16, 2021. It is now read-only.

Conversation

@benbalter
Copy link
Contributor

@benbalter benbalter commented Mar 14, 2017

This PR does two things to improve the site's SEO, specifically around the canonical URL.

  • Add Jekyll Sitemap to help Google index the site. Jekyll Sitemap is an officially supported Jekyll plugin which "just works" by adding a line to your config and exposes a sitemaps.org compatible sitemap and robots.txt file.
  • Add Jekyll SEO Tag another official Jekyll plugin, which adds canonical URL and JSON-LD metadata to each page (among other metadata like Twitter and Facebook metadata).

Here's what it looks like in action:

<!-- Begin Jekyll SEO tag v2.1.0 -->
<title>Ruby on Rails - A web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.</title>
<meta property="og:title" content="Ruby on Rails" />
<meta name="description" content="A web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern." />
<meta property="og:description" content="A web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern." />
<link rel="canonical" href="http://localhost:4000/" />
<meta property="og:url" content="http://localhost:4000/" />
<meta property="og:site_name" content="Ruby on Rails" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@rails" />
<script type="application/ld+json">
{"@context": "http://schema.org",
"@type": "WebSite",
"name": "Ruby on Rails",
"headline": "Ruby on Rails",
"description": "A web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.",
"url": "http://localhost:4000/"}</script>
<!-- End Jekyll SEO tag -->

or for a page:

<!-- Begin Jekyll SEO tag v2.1.0 -->
<title>Maintenance policy - Ruby on Rails</title>
<meta property="og:title" content="Maintenance policy" />
<meta name="description" content="Support of the Rails framework is divided into four groups: New features, bug fixes, security issues, and severe security issues. They are handled as follows, all versions in X.Y.Z format." />
<meta property="og:description" content="Support of the Rails framework is divided into four groups: New features, bug fixes, security issues, and severe security issues. They are handled as follows, all versions in X.Y.Z format." />
<link rel="canonical" href="http://localhost:4000/maintenance/" />
<meta property="og:url" content="http://localhost:4000/maintenance/" />
<meta property="og:site_name" content="Ruby on Rails" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@rails" />
<script type="application/ld+json">
{"@context": "http://schema.org",
"@type": "WebPage",
"headline": "Maintenance policy",
"description": "Support of the Rails framework is divided into four groups: New features, bug fixes, security issues, and severe security issues. They are handled as follows, all versions in X.Y.Z format.",
"url": "http://localhost:4000/maintenance/"}</script>
<!-- End Jekyll SEO tag -->

There should be no additional configuration or workflow changes required.

Finally, I also added Gemfile.lock to .gitignore (since dependency versions are locked explicitly by the pages gem and you don't want to lock them locally at an older version) and added the gem to the jekyll_plugins group so that it can set defaults locally that more closely match production.

/cc @tenderlove, @eileencodes

This allows the gem to hook into the Jekyll bootstrap process earlier
and set defaults so that local development more closely matches production.
@benbalter
Copy link
Contributor Author

Also to note, it looks like Rails is already using both on http://weblog.rubyonrails.org/.

@pixeltrix pixeltrix merged commit c812b55 into rails:master Mar 16, 2017
@pixeltrix
Copy link
Contributor

@benbalter thanks! 👍

Also to note, it looks like Rails is already using both on http://weblog.rubyonrails.org/.

Yes, the changes were made in rails/weblog#88.

@benbalter benbalter deleted the benbalter-seo branch March 16, 2017 13:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants