better_seo 0.13.0 β 1.0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +121 -3
- data/README.md +299 -181
- data/docs/00_OVERVIEW.md +472 -0
- data/docs/01_CORE_AND_CONFIGURATION.md +913 -0
- data/docs/02_META_TAGS_AND_OPEN_GRAPH.md +251 -0
- data/docs/03_STRUCTURED_DATA.md +140 -0
- data/docs/04_SITEMAP_AND_ROBOTS.md +131 -0
- data/docs/05_RAILS_INTEGRATION.md +175 -0
- data/docs/06_I18N_PAGE_GENERATOR.md +233 -0
- data/docs/07_IMAGE_OPTIMIZATION.md +260 -0
- data/docs/DEPENDENCIES.md +383 -0
- data/docs/README.md +180 -0
- data/docs/TESTING_STRATEGY.md +663 -0
- data/lib/better_seo/analytics/google_analytics.rb +83 -0
- data/lib/better_seo/analytics/google_tag_manager.rb +74 -0
- data/lib/better_seo/configuration.rb +316 -0
- data/lib/better_seo/dsl/base.rb +86 -0
- data/lib/better_seo/dsl/meta_tags.rb +55 -0
- data/lib/better_seo/dsl/open_graph.rb +109 -0
- data/lib/better_seo/dsl/twitter_cards.rb +131 -0
- data/lib/better_seo/errors.rb +31 -0
- data/lib/better_seo/generators/amp_generator.rb +83 -0
- data/lib/better_seo/generators/breadcrumbs_generator.rb +126 -0
- data/lib/better_seo/generators/canonical_url_manager.rb +106 -0
- data/lib/better_seo/generators/meta_tags_generator.rb +100 -0
- data/lib/better_seo/generators/open_graph_generator.rb +110 -0
- data/lib/better_seo/generators/robots_txt_generator.rb +102 -0
- data/lib/better_seo/generators/twitter_cards_generator.rb +102 -0
- data/lib/better_seo/image/optimizer.rb +143 -0
- data/lib/better_seo/rails/helpers/controller_helpers.rb +118 -0
- data/lib/better_seo/rails/helpers/seo_helper.rb +176 -0
- data/lib/better_seo/rails/helpers/structured_data_helper.rb +123 -0
- data/lib/better_seo/rails/model_helpers.rb +62 -0
- data/lib/better_seo/rails/railtie.rb +22 -0
- data/lib/better_seo/sitemap/builder.rb +65 -0
- data/lib/better_seo/sitemap/generator.rb +57 -0
- data/lib/better_seo/sitemap/sitemap_index.rb +73 -0
- data/lib/better_seo/sitemap/url_entry.rb +157 -0
- data/lib/better_seo/structured_data/article.rb +55 -0
- data/lib/better_seo/structured_data/base.rb +73 -0
- data/lib/better_seo/structured_data/breadcrumb_list.rb +49 -0
- data/lib/better_seo/structured_data/event.rb +207 -0
- data/lib/better_seo/structured_data/faq_page.rb +55 -0
- data/lib/better_seo/structured_data/generator.rb +75 -0
- data/lib/better_seo/structured_data/how_to.rb +96 -0
- data/lib/better_seo/structured_data/local_business.rb +94 -0
- data/lib/better_seo/structured_data/organization.rb +67 -0
- data/lib/better_seo/structured_data/person.rb +51 -0
- data/lib/better_seo/structured_data/product.rb +123 -0
- data/lib/better_seo/structured_data/recipe.rb +135 -0
- data/lib/better_seo/validators/seo_recommendations.rb +165 -0
- data/lib/better_seo/validators/seo_validator.rb +195 -0
- data/lib/better_seo/version.rb +1 -1
- data/lib/better_seo.rb +5 -0
- data/lib/generators/better_seo/install_generator.rb +21 -0
- data/lib/generators/better_seo/templates/README +29 -0
- data/lib/generators/better_seo/templates/better_seo.rb +40 -0
- metadata +69 -2
data/README.md
CHANGED
|
@@ -1,134 +1,218 @@
|
|
|
1
|
-
# BetterSeo
|
|
1
|
+
# π BetterSeo
|
|
2
2
|
|
|
3
|
-
A comprehensive SEO
|
|
3
|
+
> A comprehensive, production-ready SEO toolkit for Ruby and Rails applications
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
BetterSeo provides a clean, fluent DSL for managing meta tags, Open Graph, Twitter Cards, structured data, sitemaps, and advanced SEO tools. Built with 899 passing tests and 94.3% code coverage.
|
|
6
|
+
|
|
7
|
+
[](https://github.com/yourusername/better_seo)
|
|
8
|
+
[](https://github.com/yourusername/better_seo)
|
|
7
9
|
[](https://www.ruby-lang.org)
|
|
8
10
|
[](https://rubyonrails.org)
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
12
|
+
### π― Key Features at a Glance
|
|
13
|
+
|
|
14
|
+
| Feature | Description |
|
|
15
|
+
|---------|-------------|
|
|
16
|
+
| π·οΈ **Meta Tags** | Complete DSL for title, description, keywords, robots |
|
|
17
|
+
| π± **Social Media** | Open Graph & Twitter Cards with validation |
|
|
18
|
+
| πΊοΈ **Sitemaps** | XML sitemaps with hreflang, images, videos |
|
|
19
|
+
| π **Structured Data** | 10+ JSON-LD types (Article, Product, Recipe, etc.) |
|
|
20
|
+
| π€ **Robots.txt** | Dynamic robots.txt generation |
|
|
21
|
+
| β
**SEO Validator** | Score pages 0-100 with recommendations |
|
|
22
|
+
| πΌοΈ **Image Optimizer** | WebP conversion, resize, compress |
|
|
23
|
+
| π **Analytics** | Google Analytics 4 & Tag Manager |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## π Table of Contents
|
|
28
|
+
|
|
29
|
+
- [β¨ Features](#-features)
|
|
30
|
+
- [π¦ Installation](#-installation)
|
|
31
|
+
- [π Quick Start](#-quick-start)
|
|
32
|
+
- [π Core Features](#-core-features)
|
|
33
|
+
- [π·οΈ Meta Tags DSL](#οΈ-meta-tags-dsl)
|
|
34
|
+
- [π± Open Graph & Twitter Cards](#-open-graph--twitter-cards)
|
|
35
|
+
- [π― Rails Integration](#-rails-integration)
|
|
36
|
+
- [πΊοΈ Sitemap Generation](#οΈ-sitemap-generation)
|
|
37
|
+
- [π Structured Data (JSON-LD)](#-structured-data-json-ld)
|
|
38
|
+
- [π οΈ Advanced Tools](#οΈ-advanced-tools)
|
|
39
|
+
- [π Breadcrumbs Generator](#-breadcrumbs-generator)
|
|
40
|
+
- [β‘ AMP Support](#-amp-support)
|
|
41
|
+
- [π Canonical URL Manager](#-canonical-url-manager)
|
|
42
|
+
- [π€ Robots.txt Generator](#-robotstxt-generator)
|
|
43
|
+
- [β
SEO Validator & Recommendations](#-seo-validator--recommendations)
|
|
44
|
+
- [πΌοΈ Image Optimizer](#οΈ-image-optimizer)
|
|
45
|
+
- [π Analytics Integration](#-analytics-integration)
|
|
46
|
+
- [βοΈ Configuration](#οΈ-configuration)
|
|
47
|
+
- [π» Development](#-development)
|
|
48
|
+
- [π€ Contributing](#-contributing)
|
|
49
|
+
- [π License](#-license)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## β‘ Quick Reference
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
# 1οΈβ£ Install
|
|
57
|
+
gem 'better_seo', '~> 1.0'
|
|
58
|
+
|
|
59
|
+
# 2οΈβ£ Configure
|
|
60
|
+
BetterSeo.configure do |config|
|
|
61
|
+
config.site_name = "My Site"
|
|
62
|
+
config.meta_tags.default_title = "Default Title"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# 3οΈβ£ Use in Views
|
|
66
|
+
<%= seo_tags do |seo|
|
|
67
|
+
seo.meta { |m| m.title("Page Title").description("Description") }
|
|
68
|
+
seo.og { |og| og.type("article").image(image_url) }
|
|
69
|
+
seo.twitter { |t| t.card("summary_large_image") }
|
|
70
|
+
end %>
|
|
71
|
+
|
|
72
|
+
# 4οΈβ£ Generate Sitemap
|
|
73
|
+
xml = BetterSeo::Sitemap::Generator.generate do |sitemap|
|
|
74
|
+
sitemap.add_url("https://example.com", priority: 1.0)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# 5οΈβ£ Add Structured Data
|
|
78
|
+
<%= article_sd(headline: @post.title, author: @post.author.name) %>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## β¨ Features
|
|
84
|
+
|
|
85
|
+
### π― Core Capabilities (v1.0.0 - Production Ready)
|
|
86
|
+
|
|
87
|
+
<details>
|
|
88
|
+
<summary><b>ποΈ Core Configuration System</b></summary>
|
|
89
|
+
|
|
90
|
+
- βοΈ Singleton configuration with block-style setup
|
|
91
|
+
- π§ Nested configuration objects
|
|
92
|
+
- π© Feature flags for enabling/disabling modules
|
|
93
|
+
- β
Validation with detailed error messages
|
|
94
|
+
- π i18n support with multiple locales
|
|
95
|
+
</details>
|
|
96
|
+
|
|
97
|
+
<details>
|
|
98
|
+
<summary><b>π·οΈ DSL Builders</b></summary>
|
|
99
|
+
|
|
100
|
+
- **Meta Tags**: title, description, keywords, author, canonical, robots, viewport, charset
|
|
101
|
+
- **Open Graph**: Complete OG protocol including articles, images, videos, audio
|
|
102
|
+
- **Twitter Cards**: All card types (summary, summary_large_image, app, player)
|
|
103
|
+
- π Fluent interface with method chaining
|
|
104
|
+
- β
Automatic validation (length, required fields)
|
|
105
|
+
</details>
|
|
106
|
+
|
|
107
|
+
<details>
|
|
108
|
+
<summary><b>π¨ HTML Generators</b></summary>
|
|
109
|
+
|
|
110
|
+
- π·οΈ **MetaTagsGenerator**: Converts DSL to HTML meta tags
|
|
111
|
+
- π± **OpenGraphGenerator**: Open Graph meta tags
|
|
112
|
+
- π¦ **TwitterCardsGenerator**: Twitter Card meta tags
|
|
113
|
+
- π **BreadcrumbsGenerator**: HTML breadcrumbs with Schema.org
|
|
114
|
+
- β‘ **AMP Generator**: Accelerated Mobile Pages support
|
|
115
|
+
- π **Canonical URL Manager**: URL normalization and management
|
|
116
|
+
- π HTML entity escaping for security
|
|
117
|
+
</details>
|
|
118
|
+
|
|
119
|
+
<details>
|
|
120
|
+
<summary><b>π― Rails Integration</b></summary>
|
|
121
|
+
|
|
122
|
+
- **View Helpers**: `seo_meta_tags`, `seo_open_graph_tags`, `seo_twitter_tags`, `seo_tags`
|
|
123
|
+
- **Structured Data Helpers**: 10+ helpers for all Schema.org types
|
|
124
|
+
- **Controller Helpers**: `set_page_title`, `set_page_description`, `set_page_keywords`, and more
|
|
125
|
+
- **Model Helpers**: `seo_attributes` macro for automatic SEO
|
|
126
|
+
- **Railtie**: Automatic initialization and helper injection
|
|
127
|
+
- **Generator**: `rails generate better_seo:install`
|
|
128
|
+
</details>
|
|
129
|
+
|
|
130
|
+
<details>
|
|
131
|
+
<summary><b>πΊοΈ Sitemap Generation</b></summary>
|
|
132
|
+
|
|
133
|
+
- π XML Sitemap Builder with fluent API
|
|
134
|
+
- π Multi-language support (hreflang alternates)
|
|
135
|
+
- πΌοΈ Image sitemaps with title and caption
|
|
136
|
+
- π₯ Video sitemaps with metadata
|
|
137
|
+
- π Sitemap Index for 50,000+ URLs
|
|
138
|
+
- π Dynamic generation with lambda support
|
|
139
|
+
- πΎ File writing capabilities
|
|
140
|
+
- β
Automatic URL validation
|
|
141
|
+
</details>
|
|
142
|
+
|
|
143
|
+
<details>
|
|
144
|
+
<summary><b>π Structured Data (JSON-LD)</b></summary>
|
|
145
|
+
|
|
146
|
+
**10 comprehensive Schema.org types:**
|
|
147
|
+
- π’ **Organization**: Company info with address, social profiles
|
|
148
|
+
- π° **Article**: Blog posts with author, publisher, metadata
|
|
149
|
+
- π€ **Person**: Author profiles with job title, social links
|
|
150
|
+
- ποΈ **Product**: E-commerce with price, ratings, reviews
|
|
151
|
+
- π **BreadcrumbList**: Navigation breadcrumbs
|
|
152
|
+
- πͺ **LocalBusiness**: Physical locations with hours, geo coordinates
|
|
153
|
+
- π« **Event**: Conferences, webinars with dates, tickets
|
|
154
|
+
- β **FAQPage**: Structured FAQ for rich snippets
|
|
155
|
+
- π **HowTo**: Step-by-step guides
|
|
156
|
+
- π³ **Recipe**: Cooking recipes with ingredients, nutrition
|
|
157
|
+
|
|
158
|
+
β¨ Full Rails integration with dedicated view helpers
|
|
159
|
+
</details>
|
|
160
|
+
|
|
161
|
+
<details>
|
|
162
|
+
<summary><b>π οΈ Advanced SEO Tools</b></summary>
|
|
163
|
+
|
|
164
|
+
- π€ **Robots.txt Generator**: Control crawler access
|
|
165
|
+
- β
**SEO Validator**: Page scoring (0-100) with detailed reports
|
|
166
|
+
- π‘ **SEO Recommendations**: AI-powered suggestions by priority
|
|
167
|
+
- πΌοΈ **Image Optimizer**: WebP conversion, resize, compress
|
|
168
|
+
- π **Google Analytics 4**: GA4 integration
|
|
169
|
+
- π·οΈ **Google Tag Manager**: GTM support with custom events
|
|
170
|
+
</details>
|
|
171
|
+
|
|
172
|
+
## π¦ Installation
|
|
173
|
+
|
|
174
|
+
### π Production Use (RubyGems)
|
|
175
|
+
|
|
176
|
+
Add to your `Gemfile`:
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
gem 'better_seo', '~> 1.0'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Then run:
|
|
99
183
|
|
|
100
184
|
```bash
|
|
101
185
|
bundle install
|
|
102
186
|
```
|
|
103
187
|
|
|
104
|
-
Or install
|
|
188
|
+
Or install directly:
|
|
105
189
|
|
|
106
190
|
```bash
|
|
107
191
|
gem install better_seo
|
|
108
192
|
```
|
|
109
193
|
|
|
110
|
-
###
|
|
194
|
+
### π§ Development (from source)
|
|
111
195
|
|
|
112
|
-
|
|
196
|
+
**From Git:**
|
|
113
197
|
|
|
114
198
|
```ruby
|
|
115
|
-
gem 'better_seo', git: 'https://github.com/alessiobussolari/better_seo.git', tag: '
|
|
199
|
+
gem 'better_seo', git: 'https://github.com/alessiobussolari/better_seo.git', tag: 'v1.0.0'
|
|
116
200
|
```
|
|
117
201
|
|
|
118
|
-
|
|
202
|
+
**Clone and build locally:**
|
|
119
203
|
|
|
120
204
|
```bash
|
|
121
205
|
git clone https://github.com/alessiobussolari/better_seo.git
|
|
122
206
|
cd better_seo
|
|
123
207
|
gem build better_seo.gemspec
|
|
124
|
-
gem install better_seo-0.
|
|
208
|
+
gem install better_seo-1.0.0.gem
|
|
125
209
|
```
|
|
126
210
|
|
|
127
|
-
## Quick Start
|
|
211
|
+
## π Quick Start
|
|
128
212
|
|
|
129
|
-
### 1
|
|
213
|
+
### 1οΈβ£ Configuration
|
|
130
214
|
|
|
131
|
-
Create an initializer
|
|
215
|
+
Create an initializer in Rails or configure at app startup:
|
|
132
216
|
|
|
133
217
|
```ruby
|
|
134
218
|
# config/initializers/better_seo.rb
|
|
@@ -156,9 +240,9 @@ BetterSeo.configure do |config|
|
|
|
156
240
|
end
|
|
157
241
|
```
|
|
158
242
|
|
|
159
|
-
### 2
|
|
243
|
+
### 2οΈβ£ Using DSL Builders
|
|
160
244
|
|
|
161
|
-
#### Meta Tags
|
|
245
|
+
#### π·οΈ Meta Tags
|
|
162
246
|
|
|
163
247
|
```ruby
|
|
164
248
|
meta = BetterSeo::DSL::MetaTags.new
|
|
@@ -184,7 +268,7 @@ config = meta.build
|
|
|
184
268
|
# }
|
|
185
269
|
```
|
|
186
270
|
|
|
187
|
-
#### Open Graph
|
|
271
|
+
#### π± Open Graph
|
|
188
272
|
|
|
189
273
|
```ruby
|
|
190
274
|
og = BetterSeo::DSL::OpenGraph.new
|
|
@@ -212,7 +296,7 @@ end
|
|
|
212
296
|
config = og.build
|
|
213
297
|
```
|
|
214
298
|
|
|
215
|
-
#### Twitter Cards
|
|
299
|
+
#### π¦ Twitter Cards
|
|
216
300
|
|
|
217
301
|
```ruby
|
|
218
302
|
twitter = BetterSeo::DSL::TwitterCards.new
|
|
@@ -230,7 +314,7 @@ end
|
|
|
230
314
|
config = twitter.build
|
|
231
315
|
```
|
|
232
316
|
|
|
233
|
-
#### Method Chaining
|
|
317
|
+
#### π Method Chaining
|
|
234
318
|
|
|
235
319
|
All DSL builders support fluent interface:
|
|
236
320
|
|
|
@@ -256,11 +340,11 @@ twitter = BetterSeo::DSL::TwitterCards.new
|
|
|
256
340
|
.image("https://example.com/twitter.jpg")
|
|
257
341
|
```
|
|
258
342
|
|
|
259
|
-
### 3
|
|
343
|
+
### 3οΈβ£ HTML Generation
|
|
260
344
|
|
|
261
345
|
Once you've built your SEO configuration with DSL builders, use generators to convert them to HTML tags:
|
|
262
346
|
|
|
263
|
-
#### Meta Tags Generator
|
|
347
|
+
#### π¨ Meta Tags Generator
|
|
264
348
|
|
|
265
349
|
```ruby
|
|
266
350
|
# Build configuration with DSL
|
|
@@ -285,7 +369,7 @@ html = generator.generate
|
|
|
285
369
|
# <meta name="robots" content="index, follow">
|
|
286
370
|
```
|
|
287
371
|
|
|
288
|
-
#### Open Graph Generator
|
|
372
|
+
#### π± Open Graph Generator
|
|
289
373
|
|
|
290
374
|
```ruby
|
|
291
375
|
# Build configuration with DSL
|
|
@@ -308,7 +392,7 @@ html = generator.generate
|
|
|
308
392
|
# <meta property="og:image:height" content="630">
|
|
309
393
|
```
|
|
310
394
|
|
|
311
|
-
#### Twitter Cards Generator
|
|
395
|
+
#### π¦ Twitter Cards Generator
|
|
312
396
|
|
|
313
397
|
```ruby
|
|
314
398
|
# Build configuration with DSL
|
|
@@ -331,7 +415,7 @@ html = generator.generate
|
|
|
331
415
|
# <meta name="twitter:image" content="https://example.com/twitter.jpg">
|
|
332
416
|
```
|
|
333
417
|
|
|
334
|
-
#### Complete Example
|
|
418
|
+
#### β¨ Complete Example
|
|
335
419
|
|
|
336
420
|
```ruby
|
|
337
421
|
# Build all SEO tags for a page
|
|
@@ -364,7 +448,7 @@ twitter_html = BetterSeo::Generators::TwitterCardsGenerator.new(twitter.build).g
|
|
|
364
448
|
all_tags = [meta_html, og_html, twitter_html].join("\n")
|
|
365
449
|
```
|
|
366
450
|
|
|
367
|
-
#### Security Features
|
|
451
|
+
#### π Security Features
|
|
368
452
|
|
|
369
453
|
All generators automatically escape HTML entities to prevent XSS attacks:
|
|
370
454
|
|
|
@@ -380,7 +464,7 @@ html = generator.generate
|
|
|
380
464
|
# All dangerous characters are properly escaped
|
|
381
465
|
```
|
|
382
466
|
|
|
383
|
-
### 4
|
|
467
|
+
### 4οΈβ£ Validation
|
|
384
468
|
|
|
385
469
|
All DSL builders include automatic validation:
|
|
386
470
|
|
|
@@ -401,11 +485,15 @@ twitter.build
|
|
|
401
485
|
# => BetterSeo::ValidationError: Invalid card type: invalid_type. Valid types: summary, summary_large_image, app, player
|
|
402
486
|
```
|
|
403
487
|
|
|
404
|
-
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## π Core Features
|
|
405
491
|
|
|
406
|
-
|
|
492
|
+
### π― Rails Integration
|
|
407
493
|
|
|
408
|
-
|
|
494
|
+
BetterSeo provides comprehensive view helpers for seamless Rails integration.
|
|
495
|
+
|
|
496
|
+
#### π§ Setup
|
|
409
497
|
|
|
410
498
|
Include the helpers in your `ApplicationHelper`:
|
|
411
499
|
|
|
@@ -425,9 +513,9 @@ class ApplicationController < ActionController::Base
|
|
|
425
513
|
end
|
|
426
514
|
```
|
|
427
515
|
|
|
428
|
-
#### Using View Helpers
|
|
516
|
+
#### π¨ Using View Helpers
|
|
429
517
|
|
|
430
|
-
##### Single Tag Group Helpers
|
|
518
|
+
##### π·οΈ Single Tag Group Helpers
|
|
431
519
|
|
|
432
520
|
```erb
|
|
433
521
|
<%# app/views/layouts/application.html.erb %>
|
|
@@ -458,7 +546,7 @@ end
|
|
|
458
546
|
</head>
|
|
459
547
|
```
|
|
460
548
|
|
|
461
|
-
##### All-in-One Helper
|
|
549
|
+
##### β¨ All-in-One Helper
|
|
462
550
|
|
|
463
551
|
```erb
|
|
464
552
|
<%# Generate all SEO tags at once %>
|
|
@@ -597,11 +685,11 @@ Then use it in your views:
|
|
|
597
685
|
og_image: url_for(@article.cover_image) %>
|
|
598
686
|
```
|
|
599
687
|
|
|
600
|
-
###
|
|
688
|
+
### πΊοΈ Sitemap Generation
|
|
601
689
|
|
|
602
690
|
BetterSeo provides a comprehensive sitemap generation system with support for XML sitemaps, dynamic content, and model collections.
|
|
603
691
|
|
|
604
|
-
#### Basic Sitemap Generation
|
|
692
|
+
#### π Basic Sitemap Generation
|
|
605
693
|
|
|
606
694
|
Generate a simple sitemap using the block syntax:
|
|
607
695
|
|
|
@@ -624,7 +712,7 @@ puts xml
|
|
|
624
712
|
# </urlset>
|
|
625
713
|
```
|
|
626
714
|
|
|
627
|
-
#### URL Entry with Full Attributes
|
|
715
|
+
#### βοΈ URL Entry with Full Attributes
|
|
628
716
|
|
|
629
717
|
Add URLs with all sitemap attributes (lastmod, changefreq, priority):
|
|
630
718
|
|
|
@@ -656,7 +744,7 @@ end
|
|
|
656
744
|
|
|
657
745
|
**Priority range**: 0.0 to 1.0 (default: 0.5)
|
|
658
746
|
|
|
659
|
-
#### Method Chaining
|
|
747
|
+
#### π Method Chaining
|
|
660
748
|
|
|
661
749
|
The builder supports fluent method chaining:
|
|
662
750
|
|
|
@@ -1033,11 +1121,11 @@ end
|
|
|
1033
1121
|
# SitemapGeneratorService.generate
|
|
1034
1122
|
```
|
|
1035
1123
|
|
|
1036
|
-
###
|
|
1124
|
+
### π Structured Data (JSON-LD)
|
|
1037
1125
|
|
|
1038
1126
|
BetterSeo provides comprehensive support for Schema.org structured data using JSON-LD format, helping search engines better understand your content.
|
|
1039
1127
|
|
|
1040
|
-
#### Basic Usage
|
|
1128
|
+
#### π‘ Basic Usage
|
|
1041
1129
|
|
|
1042
1130
|
Create structured data objects and generate JSON-LD script tags:
|
|
1043
1131
|
|
|
@@ -1061,9 +1149,9 @@ org.to_script_tag
|
|
|
1061
1149
|
# </script>
|
|
1062
1150
|
```
|
|
1063
1151
|
|
|
1064
|
-
#### Available Types
|
|
1152
|
+
#### π Available Types
|
|
1065
1153
|
|
|
1066
|
-
|
|
1154
|
+
**π’ Organization** - Company/organization information:
|
|
1067
1155
|
|
|
1068
1156
|
```ruby
|
|
1069
1157
|
org = BetterSeo::StructuredData::Organization.new
|
|
@@ -1087,7 +1175,7 @@ org.same_as([
|
|
|
1087
1175
|
org.founding_date("2015-03-20")
|
|
1088
1176
|
```
|
|
1089
1177
|
|
|
1090
|
-
|
|
1178
|
+
**π° Article** - Blog posts, news articles, content:
|
|
1091
1179
|
|
|
1092
1180
|
```ruby
|
|
1093
1181
|
article = BetterSeo::StructuredData::Article.new
|
|
@@ -1103,7 +1191,7 @@ article.keywords(["Web Development", "Technology", "Trends"])
|
|
|
1103
1191
|
article.article_section("Technology")
|
|
1104
1192
|
```
|
|
1105
1193
|
|
|
1106
|
-
|
|
1194
|
+
**π€ Person** - Author profiles, team members:
|
|
1107
1195
|
|
|
1108
1196
|
```ruby
|
|
1109
1197
|
person = BetterSeo::StructuredData::Person.new
|
|
@@ -1121,7 +1209,7 @@ person.same_as([
|
|
|
1121
1209
|
])
|
|
1122
1210
|
```
|
|
1123
1211
|
|
|
1124
|
-
|
|
1212
|
+
**ποΈ Product** - E-commerce products:
|
|
1125
1213
|
|
|
1126
1214
|
```ruby
|
|
1127
1215
|
product = BetterSeo::StructuredData::Product.new
|
|
@@ -1142,7 +1230,7 @@ product.aggregate_rating(
|
|
|
1142
1230
|
)
|
|
1143
1231
|
```
|
|
1144
1232
|
|
|
1145
|
-
|
|
1233
|
+
**π BreadcrumbList** - Navigation breadcrumbs:
|
|
1146
1234
|
|
|
1147
1235
|
```ruby
|
|
1148
1236
|
breadcrumb = BetterSeo::StructuredData::BreadcrumbList.new
|
|
@@ -1532,13 +1620,13 @@ all_tags = BetterSeo::StructuredData::Generator.generate_script_tags([
|
|
|
1532
1620
|
|
|
1533
1621
|
---
|
|
1534
1622
|
|
|
1535
|
-
## Advanced
|
|
1623
|
+
## π οΈ Advanced Tools
|
|
1536
1624
|
|
|
1537
|
-
### Breadcrumbs Generator
|
|
1625
|
+
### π Breadcrumbs Generator
|
|
1538
1626
|
|
|
1539
1627
|
Generate HTML breadcrumb navigation with Schema.org structured data support.
|
|
1540
1628
|
|
|
1541
|
-
#### Basic Usage
|
|
1629
|
+
#### π‘ Basic Usage
|
|
1542
1630
|
|
|
1543
1631
|
```ruby
|
|
1544
1632
|
generator = BetterSeo::Generators::BreadcrumbsGenerator.new
|
|
@@ -1607,11 +1695,11 @@ generator.add_items([
|
|
|
1607
1695
|
|
|
1608
1696
|
---
|
|
1609
1697
|
|
|
1610
|
-
### AMP Generator
|
|
1698
|
+
### β‘ AMP Generator
|
|
1611
1699
|
|
|
1612
1700
|
Generate Accelerated Mobile Pages (AMP) HTML components.
|
|
1613
1701
|
|
|
1614
|
-
#### Basic Usage
|
|
1702
|
+
#### π‘ Basic Usage
|
|
1615
1703
|
|
|
1616
1704
|
```ruby
|
|
1617
1705
|
amp = BetterSeo::Generators::AmpGenerator.new(
|
|
@@ -1693,11 +1781,11 @@ end
|
|
|
1693
1781
|
|
|
1694
1782
|
---
|
|
1695
1783
|
|
|
1696
|
-
### Canonical URL Manager
|
|
1784
|
+
### π Canonical URL Manager
|
|
1697
1785
|
|
|
1698
1786
|
Manage and normalize canonical URLs with validation.
|
|
1699
1787
|
|
|
1700
|
-
#### Basic Usage
|
|
1788
|
+
#### π‘ Basic Usage
|
|
1701
1789
|
|
|
1702
1790
|
```ruby
|
|
1703
1791
|
manager = BetterSeo::Generators::CanonicalUrlManager.new("https://example.com/page")
|
|
@@ -1793,13 +1881,11 @@ manager.validate! # Raises: "URL is required"
|
|
|
1793
1881
|
|
|
1794
1882
|
---
|
|
1795
1883
|
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
### Robots.txt Generator
|
|
1884
|
+
### π€ Robots.txt Generator
|
|
1799
1885
|
|
|
1800
1886
|
Generate robots.txt files to control search engine crawler access.
|
|
1801
1887
|
|
|
1802
|
-
#### Basic Usage
|
|
1888
|
+
#### π‘ Basic Usage
|
|
1803
1889
|
|
|
1804
1890
|
```ruby
|
|
1805
1891
|
robots = BetterSeo::Generators::RobotsTxtGenerator.new
|
|
@@ -1875,11 +1961,11 @@ get '/robots.txt', to: 'robots#index'
|
|
|
1875
1961
|
|
|
1876
1962
|
---
|
|
1877
1963
|
|
|
1878
|
-
### SEO Validator
|
|
1964
|
+
### β
SEO Validator & Recommendations
|
|
1879
1965
|
|
|
1880
|
-
Validate and score your pages for SEO best practices.
|
|
1966
|
+
Validate and score your pages for SEO best practices with AI-powered recommendations.
|
|
1881
1967
|
|
|
1882
|
-
#### Basic Usage
|
|
1968
|
+
#### π‘ Basic Usage
|
|
1883
1969
|
|
|
1884
1970
|
```ruby
|
|
1885
1971
|
validator = BetterSeo::Validators::SeoValidator.new
|
|
@@ -1986,9 +2072,9 @@ end
|
|
|
1986
2072
|
|
|
1987
2073
|
---
|
|
1988
2074
|
|
|
1989
|
-
## Configuration
|
|
2075
|
+
## βοΈ Configuration
|
|
1990
2076
|
|
|
1991
|
-
### Global Configuration
|
|
2077
|
+
### π§ Global Configuration
|
|
1992
2078
|
|
|
1993
2079
|
```ruby
|
|
1994
2080
|
BetterSeo.configure do |config|
|
|
@@ -2043,7 +2129,7 @@ BetterSeo.configure do |config|
|
|
|
2043
2129
|
end
|
|
2044
2130
|
```
|
|
2045
2131
|
|
|
2046
|
-
### Checking Configuration
|
|
2132
|
+
### β
Checking Configuration
|
|
2047
2133
|
|
|
2048
2134
|
```ruby
|
|
2049
2135
|
# Access configuration
|
|
@@ -2061,7 +2147,9 @@ BetterSeo.enabled?(:sitemap)
|
|
|
2061
2147
|
BetterSeo.reset_configuration!
|
|
2062
2148
|
```
|
|
2063
2149
|
|
|
2064
|
-
|
|
2150
|
+
---
|
|
2151
|
+
|
|
2152
|
+
## π» Development
|
|
2065
2153
|
|
|
2066
2154
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
|
2067
2155
|
|
|
@@ -2079,9 +2167,9 @@ bundle exec rspec --format documentation
|
|
|
2079
2167
|
open coverage/index.html
|
|
2080
2168
|
```
|
|
2081
2169
|
|
|
2082
|
-
### Running Tests
|
|
2170
|
+
### π§ͺ Running Tests
|
|
2083
2171
|
|
|
2084
|
-
The gem uses RSpec with SimpleCov for test coverage.
|
|
2172
|
+
The gem uses RSpec with SimpleCov for test coverage.
|
|
2085
2173
|
|
|
2086
2174
|
```bash
|
|
2087
2175
|
# Run all tests
|
|
@@ -2094,18 +2182,15 @@ bundle exec rspec spec/dsl/meta_tags_spec.rb
|
|
|
2094
2182
|
bundle exec rspec --format documentation
|
|
2095
2183
|
```
|
|
2096
2184
|
|
|
2097
|
-
|
|
2098
|
-
- **
|
|
2099
|
-
- **
|
|
2100
|
-
- **
|
|
2101
|
-
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
- **1 Advanced sitemap system** with hreflang, images, videos, and index
|
|
2105
|
-
- **1 Railtie and Generator** fully tested
|
|
2106
|
-
- **1 core configuration system** fully tested
|
|
2185
|
+
**π Test Statistics:**
|
|
2186
|
+
- β
**899 tests** passing
|
|
2187
|
+
- π **94.3% code coverage**
|
|
2188
|
+
- ποΈ **Complete test suite** for all modules
|
|
2189
|
+
- π **Production-ready** quality
|
|
2190
|
+
|
|
2191
|
+
---
|
|
2107
2192
|
|
|
2108
|
-
## Architecture
|
|
2193
|
+
## ποΈ Architecture
|
|
2109
2194
|
|
|
2110
2195
|
```
|
|
2111
2196
|
lib/better_seo/
|
|
@@ -2129,35 +2214,68 @@ lib/better_seo/
|
|
|
2129
2214
|
βββ sitemap/ # Sitemap generation
|
|
2130
2215
|
```
|
|
2131
2216
|
|
|
2132
|
-
|
|
2217
|
+
---
|
|
2218
|
+
|
|
2219
|
+
## π€ Contributing
|
|
2133
2220
|
|
|
2134
2221
|
Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/better_seo.
|
|
2135
2222
|
|
|
2136
|
-
1. Fork it
|
|
2137
|
-
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
|
2138
|
-
3. Write tests (we maintain
|
|
2139
|
-
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
2140
|
-
5. Push to the branch (`git push origin feature/my-new-feature`)
|
|
2141
|
-
6. Create new Pull Request
|
|
2223
|
+
1. π΄ Fork it
|
|
2224
|
+
2. πΏ Create your feature branch (`git checkout -b feature/my-new-feature`)
|
|
2225
|
+
3. β
Write tests (we maintain high test coverage)
|
|
2226
|
+
4. πΎ Commit your changes (`git commit -am 'Add some feature'`)
|
|
2227
|
+
5. π€ Push to the branch (`git push origin feature/my-new-feature`)
|
|
2228
|
+
6. π Create new Pull Request
|
|
2229
|
+
|
|
2230
|
+
---
|
|
2142
2231
|
|
|
2143
|
-
## License
|
|
2232
|
+
## π License
|
|
2144
2233
|
|
|
2145
2234
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
2146
2235
|
|
|
2147
|
-
|
|
2236
|
+
---
|
|
2237
|
+
|
|
2238
|
+
## π Code of Conduct
|
|
2148
2239
|
|
|
2149
2240
|
Everyone interacting in the BetterSeo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yourusername/better_seo/blob/main/CODE_OF_CONDUCT.md).
|
|
2150
2241
|
|
|
2151
|
-
|
|
2242
|
+
---
|
|
2243
|
+
|
|
2244
|
+
## πΊοΈ Roadmap
|
|
2152
2245
|
|
|
2153
2246
|
See [docs/00_OVERVIEW.md](docs/00_OVERVIEW.md) for the complete implementation roadmap.
|
|
2154
2247
|
|
|
2155
|
-
### Version History
|
|
2248
|
+
### π
Version History
|
|
2249
|
+
|
|
2250
|
+
- β
**v0.1.0** - Core configuration system
|
|
2251
|
+
- β
**v0.2.0** - DSL builders (Meta Tags, Open Graph, Twitter Cards)
|
|
2252
|
+
- β
**v0.3.0** - HTML generators (Meta Tags, Open Graph, Twitter Cards)
|
|
2253
|
+
- β
**v0.4.0** - Rails view helpers integration
|
|
2254
|
+
- β
**v0.5.0** - Sitemap generation
|
|
2255
|
+
- β
**v0.6.0** - Structured data (JSON-LD)
|
|
2256
|
+
- β
**v0.7.0** - Advanced Rails integration
|
|
2257
|
+
- β
**v0.8.0** - Structured data helpers
|
|
2258
|
+
- β
**v0.9.0** - Additional structured data types
|
|
2259
|
+
- β
**v0.10.0** - Rails model helpers
|
|
2260
|
+
- β
**v0.11.0** - Advanced sitemap features
|
|
2261
|
+
- β
**v0.12.0** - Advanced generators (Breadcrumbs, AMP, Canonical)
|
|
2262
|
+
- β
**v0.13.0** - SEO tools (Robots.txt, Validator, Image Optimizer, Analytics)
|
|
2263
|
+
- β
**v0.14.0** - SEO intelligence (GTM, Recommendations)
|
|
2264
|
+
- π **v1.0.0** - **Production Ready** β **Current**
|
|
2265
|
+
|
|
2266
|
+
---
|
|
2267
|
+
|
|
2268
|
+
## π Why BetterSeo?
|
|
2269
|
+
|
|
2270
|
+
- β
**Production-Ready**: 899 tests, 94.3% coverage
|
|
2271
|
+
- π **Complete Solution**: Everything you need for SEO in one gem
|
|
2272
|
+
- π― **Rails-First**: Designed specifically for Rails applications
|
|
2273
|
+
- π§ **Flexible**: Use as much or as little as you need
|
|
2274
|
+
- π **Well-Documented**: Comprehensive examples and guides
|
|
2275
|
+
- π **i18n Support**: Built-in internationalization
|
|
2276
|
+
- π **Secure**: Automatic XSS protection
|
|
2277
|
+
- π **Modern Ruby**: Built with Ruby 3.0+ and Rails 6.1+
|
|
2278
|
+
|
|
2279
|
+
---
|
|
2156
2280
|
|
|
2157
|
-
|
|
2158
|
-
- **v0.2.0** - DSL builders (Meta Tags, Open Graph, Twitter Cards)
|
|
2159
|
-
- **v0.3.0** - HTML generators (Meta Tags, Open Graph, Twitter Cards)
|
|
2160
|
-
- **v0.4.0** - Rails view helpers integration β **Current**
|
|
2161
|
-
- **v0.5.0** - Sitemap generation (planned)
|
|
2162
|
-
- **v0.6.0** - Advanced features (planned)
|
|
2163
|
-
- **v1.0.0** - Stable release (planned)
|
|
2281
|
+
Made with β€οΈ by the BetterSeo team
|