Use first paragraph as meta description fallback

The problem

We use text as fallback description, causing most of the pages to having the same description, which is bad for SEO:

<% if @item[:description] %>
  <meta name="description" content="<%= @item[:description] %>">
<% else %>
  <meta name="description" content="Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.">

The solution

Create a logic to use the fallback description as the first 150 chars after the h1.

Something like:

def meta_description

# get the page content from the main `.article-content` div:
# truncate to 150 chars
# ommision: `...`
# something like: 
# truncate(page.meta_description, :ommision => "...", :length => 150)`

end

Then call it in the head.html layout with something like:

<% if @item[:description] %>
  <meta name="description" content="<%= @item[:description] %>">
<% else %>
  <meta name="description" content="<%= @item[:meta_description] %>">

References

@axil ideas?

cc/ @mikelewis

Edited by Marcia Ramos