add meta to layout

Tom Rutgers committed Aug 20, 2018
commit d6de545ded231f4b353d310e38d6bcee278a7a9b
Showing 3 changed files with 29 additions and 15 deletions
source/layouts/_meta.slim +26 -0
@@ @@ -0,0 +1,26 @@
+ meta content=("text/html; charset=UTF-8") http-equiv="Content-Type"
+ meta charset="utf-8"
+ meta content="ie=edge" http-equiv="x-ua-compatible"
+ meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"
+
+ // Set dynamic and default meta
+ - title = current_page.data.title || "Kaldi - Middleman + Netlify CMS Example"
+ - description = current_page.data.description || "A simple example to get started with Middleman and Netlify CMS"
+ //Change this to your domain
+ - url = "https://brave-hypatia-0b12fd.netlify.com"
+ - image = current_page.data.image || "/images/uploads/homepage-hero.jpg"
+
+ title =title
+
+ meta name="description" content=description
+
+ meta property="og:title" content=title
+ meta property="og:description" content=description
+ meta property="og:image" content=(url + image_path(image))
+ meta property="og:url" content=(url + current_page.url)
+ meta property="og:type" content="website"
+
+ meta name="twitter:card" content="summary_large_image"
+ meta name="twitter:title" content=title
+ meta name="twitter:description" content=description
+ meta name="twitter:image" content=(url + image_path(image))
\ No newline at end of file
source/layouts/layout.slim +1 -7
@@ @@ -1,13 +1,7 @@
doctype html
html
head
- meta content=("text/html; charset=UTF-8") http-equiv="Content-Type"
- meta charset="utf-8"
- meta content="ie=edge" http-equiv="x-ua-compatible"
- meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"
-
- // Use the title from a page's frontmatter if it has one
- title= current_page.data.title || "Middleman"
+ = partial 'layouts/meta'
= stylesheet_link_tag "all"
source/layouts/news-detail.slim +2 -8
@@ @@ -1,14 +1,8 @@
doctype html
html
head
- meta content=("text/html; charset=UTF-8") http-equiv="Content-Type"
- meta charset="utf-8"
- meta content="ie=edge" http-equiv="x-ua-compatible"
- meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"
-
- // Use the title from a page's frontmatter if it has one
- title= current_page.data.title || "Kaldi - Middleman + Netlify CMS Example"
-
+ = partial 'layouts/meta'
+
= stylesheet_link_tag "all"
// Include netlify identity widget for user registration
script src="https://identity.netlify.com/v1/netlify-identity-widget.js" type="text/javascript"