jekyll-seo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/jekyll-seo +4 -0
  3. data/lib/jekyll-seo.rb +135 -0
  4. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f75d0ae98e2c233a14fa66548fbba564b70eca1b
4
+ data.tar.gz: 3fdc61c6dbacb61dc17aa9d7d18cae7f4855e58a
5
+ SHA512:
6
+ metadata.gz: 459c9c99cd2fd34d3636abe2c0a74be26d993ac391e6714b3bfb71b581d6269e514f8946aac1ffe9979a8b7c4cba15ba73301e70b93a39aeeceb676b28b2e72f
7
+ data.tar.gz: efdb04093ac318b0234347e5734f2cd2a1f54629f5a973aeeeb09c58b020ab09613bc170b159e3689881a6aa7b8c4b897b60fdd7ed908d6e1541e997f3978e6e
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'jekyll-seo'
4
+ puts JekyllSeo.new(ARGV[0])
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+ # Purpose: A simple script to identify SEO problems in jekyll blog posts
3
+ # License: http://github.com/bhardin/jekyll-seo/license.txt
4
+
5
+ require 'optparse'
6
+ require 'nokogiri'
7
+
8
+ class JekyllSeo
9
+ def self.new(args)
10
+
11
+ heading = [];
12
+ title = [];
13
+ url = [];
14
+ content = [];
15
+ meta_description = [];
16
+ temp = [];
17
+
18
+ options = {}
19
+
20
+ optparse = OptionParser.new do|opts|
21
+ # Set a banner, displayed at the top of the help screen.
22
+ opts.banner = "Usage: jekyll-seo -k keywords FILE"
23
+
24
+ # Define the options, and what they do
25
+ options[:verbose] = false
26
+ opts.on( '-v', '--verbose', 'Output more information' ) do
27
+ options[:verbose] = true
28
+ end
29
+
30
+ options[:keyword] = nil
31
+ opts.on( '-k', '--keyword KEYWORD', 'keyword your post should be optimized for' ) do|keyword|
32
+ options[:keyword] = keyword
33
+ end
34
+
35
+ options[:post] = nil
36
+ opts.on( '-p', '--post FILE', 'post to be analyzed' ) do|post|
37
+ options[:post] = post
38
+ end
39
+
40
+ opts.on( '-h', '--help', 'Display this screen' ) do
41
+ puts opts
42
+ exit
43
+ end
44
+ end
45
+
46
+ optparse.parse!
47
+
48
+ puts "Being verbose" if options[:verbose]
49
+ if options[:verbose]
50
+ puts "keyword: #{options[:keyword]}" if options[:keyword]
51
+ #puts "analyzing post: #{options[:post]}" if options[:post]
52
+ end
53
+
54
+ if options[:post]
55
+ f = options[:post]
56
+
57
+ puts "Analyzing Post: #{f}..."
58
+ post = Nokogiri::HTML(open(f))
59
+
60
+ # Search for keyword in heading
61
+ post.css('h1').each do |this|
62
+ if options[:verbose]
63
+ puts "heading found"
64
+ puts "heading: #{this}"
65
+ end
66
+
67
+ heading = this.to_s.scan(/#{options[:keyword]}/i)
68
+
69
+ if options[:verbose]
70
+ puts "heading-found: #{title}"
71
+ end
72
+ end
73
+
74
+ # Search for keyword in title
75
+ post.css('title').each do |this|
76
+ if options[:verbose]
77
+ puts "title found"
78
+ puts "title: #{this}"
79
+ end
80
+
81
+ title = this.to_s.scan(/#{options[:keyword]}/i)
82
+
83
+ if options[:verbose]
84
+ puts "title-found: #{title}"
85
+ end
86
+ end
87
+
88
+ # Search for keyword in body
89
+ post.css('body').each do |this|
90
+ if options[:verbose]
91
+ puts "content found"
92
+ #puts "content: #{this}"
93
+ end
94
+
95
+ content = this.to_s.scan(/#{options[:keyword]}/i)
96
+ end
97
+
98
+ # Search for keyword in Meta Description
99
+ post.css('meta').each do |this|
100
+ if this.attribute("name").to_s == "description"
101
+ if options[:verbose]
102
+ puts "Meta Description found"
103
+ puts "Meta Description: #{this.attribute('content')}"
104
+ end
105
+
106
+ meta_description = this.attribute("content").to_s.scan(/#{options[:keyword]}/i)
107
+ end
108
+ end
109
+
110
+ puts ""
111
+ puts "Article Heading: #{not heading.empty?} (#{heading.count})"
112
+ puts "Page title: #{not title.empty?} (#{title.count})"
113
+ # puts "Page URL: Yes (1)"
114
+ puts "Content: #{not content.empty?} (#{content.count})"
115
+ puts "Meta description: #{not meta_description.empty?} (#{meta_description.count})"
116
+
117
+ else
118
+ puts "No post given to analyze. Try with -h"
119
+ end
120
+
121
+ #You have not used your keyword / keyphrase in any subheading (such as an H2) in your copy.
122
+ #No images appear in this page, consider adding some as appropriate.
123
+ #The meta description is under 120 characters, however up to 156 characters are available. The available space is shorter than the usual 155 characters because Google will also include the publication date in the snippet.
124
+ #The page title contains keyword / phrase, but it does not appear at the beginning; try and move it to the beginning.
125
+ #The keyword / phrase does not appear in the URL for this page. If you decide to rename the URL be sure to check the old URL 301 redirects to the new one!
126
+ #The copy scores 68.9 in the Flesch Reading Ease test, which is considered OK to read.
127
+ #This page has 14 outbound link(s).
128
+ #The keyword density is 1.74%, which is great, the keyword was found 15 times.
129
+ #The meta description contains the primary keyword / phrase.
130
+ #There are 890 words contained in the body copy, this is greater than the 300 word recommended minimum.
131
+ #The page title is more than 40 characters and less than the recommended 70 character limit.
132
+ #The keyword appears in the first paragraph of the copy.
133
+ end
134
+
135
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-seo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Marsceill
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem that adds SEO to Jekyll based sites or blogs.
14
+ email: patrick.marsceill@gmail.com
15
+ executables:
16
+ - jekyll-seo
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/jekyll-seo
21
+ - lib/jekyll-seo.rb
22
+ homepage: http://rubygems.org/gems/
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.2.2
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Jekyll SEO Gem
46
+ test_files: []