jekyll-seo-tag 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4fb561dd5e7d5d50f523b42d1ebaba56dcca2d85
4
+ data.tar.gz: 2b062e382b6fdae514ab451ad845d94d51d08417
5
+ SHA512:
6
+ metadata.gz: d6fd4ab1da970910d6aa5a373c8b5313824061da8a84bd7c50132e8e390ac24ed1ce35bb39ba7bec93e5c9c7df95585a690af7c4bcf8b4dc15f85bf487bf8f4d
7
+ data.tar.gz: 6536b209f598ba837fa1cca1267bcf7f9ddcb61009bf0ad8b3f9635d9e240d7b7d10bd30cb10409e58fd970ad54faf5c426a7be573e3dd51c998dd146bd4ee56
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 2.2.3
3
+ before_install: gem install bundler
4
+ langauage: ruby
5
+ script: script/cibuild
6
+ sudo: false
7
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll_seo_tags.gemspec
4
+ gemspec
5
+
6
+ gem 'github-pages'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ben Balter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,73 @@
1
+ # Jekyll SEO Tag
2
+
3
+ A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.
4
+
5
+ [![Build Status](https://travis-ci.org/benbalter/jekyll-seo-tag.svg)](https://travis-ci.org/benbalter/jekyll-seo-tag)
6
+
7
+ ## What it does
8
+
9
+ Jekyll SEO Tag adds the following meta tags to your site:
10
+
11
+ * Pages title (with site title appended when available)
12
+ * Page description
13
+ * Canonical URL
14
+ * Next and previous URLs for posts
15
+ * [JSON-LD Site and post metadata](https://developers.google.com/structured-data/) for richer indexing
16
+ * [Open graph](http://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
17
+ * [Twitter summary card](https://dev.twitter.com/cards/overview) metadata
18
+
19
+ While you could theoretically add the necessary metadata tags yourself, Jekyll SEO Tag provides a battle-tested template of crowdsourced best-practices.
20
+
21
+ ## What it doesn't do
22
+
23
+ Jekyll SEO tag is designed to output machine-readable metadata for search engines and social networks to index and display. If you're looking for something to analyze your Jekyll site's structure and content (e.g., more traditional SEO optimization), take a look at [The Jekyll SEO Gem](https://github.com/pmarsceill/jekyll-seo-gem).
24
+
25
+ Jekyll SEO tag isn't designed to accommodate every possible use case. It should work for most site out of the box and without a laundry list of configuration options that serve only to confuse most users.
26
+
27
+ ## Installation
28
+
29
+ 1. Add the following to your site's `Gemfile`:
30
+
31
+ ```ruby
32
+ gem 'jekyll-seo-tag'
33
+ ```
34
+
35
+ 2. Add the following to your site's `_config.yml`:
36
+
37
+ ```yml
38
+ gems:
39
+ - jekyll-seo-tag
40
+ ```
41
+
42
+ 3. Add the following right before `</head>` in your site's template(s):
43
+
44
+ ```liquid
45
+ {% seo %}
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ The SEO tag will respect any of the following if included in your site's `_config.yml` (and simply not include them if they're not defined):
51
+
52
+ * `title` - Your site's title (e.g., Ben's awesome site, The GitHub Blog, etc.)
53
+ * `description` - A short description (e.g., A blog dedicated to reviewing cat gifs)
54
+ * `url` - The full URL to your site. Note: `site.github.url` will be used by default.
55
+ * `twitter:username` - The site's Twitter handle. You'll want to describe it like so:
56
+
57
+ ```yml
58
+ twitter:
59
+ username: benbalter
60
+ ```
61
+
62
+ * `logo` - Relative URL to a site-wide logo (e.g., `assets/your-company-logo.png`)
63
+ * `social` - For [specifying social profiles](https://developers.google.com/structured-data/customize/social-profiles). The following properties are available:
64
+ * `type` - Either `person` or `organization` (defaults to `person`)
65
+ * `name` - If the user or organization name differs from the site's name
66
+ * `links` - An array of links to social media profiles.
67
+
68
+ The SEO tag will respect the following YAML front matter if included in a post, page, or document:
69
+
70
+ * `title` - The title of the post, page, or document
71
+ * `description` - A short description of the page's content
72
+ * `image` - The absolute URL to an image that should be associated with the post, page, or document
73
+ * `author` - The username of the post, page, or document author
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll_seo_tags"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-seo-tag"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Ben Balter"]
9
+ spec.email = ["ben.balter@github.com"]
10
+ spec.summary = %q{A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.}
11
+ spec.homepage = "https://github.com/benbalter/jekyll-seo-tag"
12
+ spec.license = "MIT"
13
+
14
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
15
+ # delete this section to allow pushing this gem to any host.
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
18
+ else
19
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
20
+ end
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency "jekyll", "~> 2.4"
28
+ spec.add_development_dependency "bundler", "~> 1.10"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.3"
31
+ end
@@ -0,0 +1,37 @@
1
+ module Jekyll
2
+ class SeoTag < Liquid::Tag
3
+
4
+ attr_accessor :context
5
+
6
+ def render(context)
7
+ @context = context
8
+ Liquid::Template.parse(template_contents).render!(payload, info).gsub(/[\n\s]{2,}/, "\n")
9
+ end
10
+
11
+ private
12
+
13
+ def payload
14
+ {
15
+ "page" => context.registers[:page],
16
+ "site" => context.registers[:site].site_payload["site"]
17
+ }
18
+ end
19
+
20
+ def info
21
+ {
22
+ :registers => context.registers,
23
+ :filters => [Jekyll::Filters]
24
+ }
25
+ end
26
+
27
+ def template_contents
28
+ @template_contents ||= File.read(template_path)
29
+ end
30
+
31
+ def template_path
32
+ @template_path ||= File.expand_path "./template.html", File.dirname(__FILE__)
33
+ end
34
+ end
35
+ end
36
+
37
+ Liquid::Template.register_tag('seo', Jekyll::SeoTag)
@@ -0,0 +1,120 @@
1
+ <!-- Begin Jekyll SEO tag -->
2
+
3
+ {% if site.url %}
4
+ {% assign seo_url = site.url %}
5
+ {% elsif site.github.url %}
6
+ {% assign seo_url = site.github.url %}
7
+ {% endif %}
8
+
9
+ {% if page.title %}
10
+ {% assign seo_title = page.title %}
11
+ {% if site.title %}
12
+ {% assign seo_title = seo_title | append:" - " | append: site.title %}
13
+ {% endif %}
14
+ {% elsif site.title %}
15
+ {% assign seo_title = site.title %}
16
+ {% if site.description %}
17
+ {% assign seo_title = seo_title | append:" - " | append: site.description %}
18
+ {% endif %}
19
+ {% endif %}
20
+ {% if seo_title %}
21
+ {% assign seo_title = seo_title | escape | markdownify | strip_html | strip_newlines %}
22
+ {% endif %}
23
+
24
+ {% if page.description %}
25
+ {% assign seo_description = page.description %}
26
+ {% elsif site.description %}
27
+ {% assign seo_description = site.description %}
28
+ {% endif %}
29
+ {% if seo_description %}
30
+ {% assign seo_description = seo_description | escape | markdownify | strip_html | strip_newlines %}
31
+ {% endif %}
32
+
33
+ {% if seo_title %}
34
+ <title>{{ seo_title }}</title>
35
+ <meta property="og:title" content="{{ seo_title }}" />
36
+ {% endif %}
37
+
38
+ {% if seo_description %}
39
+ <meta name="description" content="{{ seo_description }}" />
40
+ <meta property='og:description' content="{{ seo_description }}" />
41
+ {% endif %}
42
+
43
+ {% if seo_url %}
44
+ <link rel="canonical" href="{{ seo_url }}{{ page.url }}" itemprop="url" />
45
+ <meta property='og:url' content='{{ seo_url }}{{ page.url }}' />
46
+ {% endif %}
47
+
48
+ {% if site.title %}
49
+ <meta property="og:site_name" content="{{ site.title }}" />
50
+ <script type="application/ld+json">
51
+ {
52
+ "@context" : "http://schema.org",
53
+ "@type" : "WebSite",
54
+ "name" : {{ site.title | jsonify }},
55
+ "url" : {{ seo_url | jsonify }}
56
+ }
57
+ </script>
58
+ {% endif %}
59
+
60
+ {% if page.image %}
61
+ <meta property="og:image" content="{{ page.image }}" />
62
+ {% endif %}
63
+
64
+ {% if page.date %}
65
+ <meta property="og:type" content="article" />
66
+ {% if page.next.url %}
67
+ <link rel="next" href="{{ seo_url }}{{ page.next.url }}" title="{{ page.next.title | escape }}" />
68
+ {% endif %}
69
+ {% if page.previous.url %}
70
+ <link rel="prev" href="{{ seo_url }}{{ page.previous.url }}" title="{{ page.previous.title | escape }}" />
71
+ {% endif %}
72
+ <script type="application/ld+json">
73
+ {
74
+ "@context": "http://schema.org",
75
+ "@type": "NewsArticle",
76
+ "headline": {{ page.title | jsonify }},
77
+ "image": {{ page.image | jsonify }},
78
+ "datePublished": {{ page.date | date_to_xmlschema | jsonify }},
79
+ "description": {{ page.description | jsonify }}
80
+ }
81
+ </script>
82
+ {% endif %}
83
+
84
+ {% if site.twitter %}
85
+ <meta name="twitter:card" content="summary" />
86
+ <meta name="twitter:site" content="@{{ site.twitter.username | replace:"@","" }}" />
87
+ <meta name="twitter:title" content="{{ seo_title }}" />
88
+ <meta name="twitter:description" content="{{ seo_description }}" />
89
+ {% if page.image %}
90
+ <meta name="twitter:image" content="{{ page.image | escape }}" />
91
+ {% endif %}
92
+ {% if page.author %}
93
+ <meta name="twitter:creator" content="@{{ page.author | replace:"@","" }}" />
94
+ {% endif %}
95
+ {% endif %}
96
+
97
+ {% if site.logo %}
98
+ <script type="application/ld+json">
99
+ {
100
+ "@context": "http://schema.org",
101
+ "@type": "Organization",
102
+ "url": {{ seo_url | jsonify }},
103
+ "logo": {{ site.logo | prepend: "/" | prepend: seo_url | jsonify }}
104
+ }
105
+ </script>
106
+ {% endif %}
107
+
108
+ {% if site.social %}
109
+ <script type="application/ld+json">
110
+ {
111
+ "@context" : "http://schema.org",
112
+ "@type" : "{% if site.social.type %}{{ site.social.type }}{% else %}person{% endif %}",
113
+ "name" : "{% if site.social.name %}{{ site.social.name }}{% else %}{{ site.title }}{% endif %}",
114
+ "url" : {{ seo_url | jsonify }},
115
+ "sameAs" : {{ site.social.links | jsonify }}
116
+ }
117
+ </script>
118
+ {% endif %}
119
+
120
+ <!-- End Jekyll SEO tag -->
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ set -ex
4
+
5
+ bundle install
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ set -ex
4
+
5
+ bundle exec rake spec
6
+ bundle exec gem build jekyll-seo-tag.gemspec
@@ -0,0 +1,38 @@
1
+ #!/bin/sh
2
+ # Tag and push a release.
3
+
4
+ set -e
5
+
6
+ # Make sure we're in the project root.
7
+
8
+ cd $(dirname "$0")/..
9
+
10
+ # Build a new gem archive.
11
+
12
+ rm -rf jekyll-seo-tag-*.gem
13
+ gem build -q jekyll-seo-tag.gemspec
14
+
15
+ # Make sure we're on the master branch.
16
+
17
+ (git branch | grep -q '* master') || {
18
+ echo "Only release from the master branch."
19
+ exit 1
20
+ }
21
+
22
+ # Figure out what version we're releasing.
23
+
24
+ tag=v`ls jekyll-seo-tag-*.gem | sed 's/^jekyll-seo-tag-\(.*\)\.gem$/\1/'`
25
+
26
+ # Make sure we haven't released this version before.
27
+
28
+ git fetch -t origin
29
+
30
+ (git tag -l | grep -q "$tag") && {
31
+ echo "Whoops, there's already a '${tag}' tag."
32
+ exit 1
33
+ }
34
+
35
+ # Tag it and bag it.
36
+
37
+ gem push jekyll-seo-tag-*.gem && git tag "$tag" &&
38
+ git push origin master && git push origin "$tag"
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-seo-tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Balter
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.3'
69
+ description:
70
+ email:
71
+ - ben.balter@github.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - jekyll-seo-tag.gemspec
86
+ - lib/jekyll-seo-tag.rb
87
+ - lib/template.html
88
+ - script/bootstrap
89
+ - script/cibuild
90
+ - script/release
91
+ homepage: https://github.com/benbalter/jekyll-seo-tag
92
+ licenses:
93
+ - MIT
94
+ metadata:
95
+ allowed_push_host: https://rubygems.org
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.8
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: A Jekyll plugin to add metadata tags for search engines and social networks
116
+ to better index and display your site's content.
117
+ test_files: []
118
+ has_rdoc: