From 8206b4a2d7b4598bd6558a4db563278610f8fda6 Mon Sep 17 00:00:00 2001 From: AJ-Kulundu Date: Sat, 20 May 2023 11:36:26 +0300 Subject: [PATCH 1/7] Creating a dynamic title for the display pages --- app/views/chapters/index.html.erb | 1 + app/views/landing/about.html.erb | 1 + app/views/landing/learn.html.erb | 1 + app/views/layouts/application.html.erb | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index de238046..9d440bf8 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:title,"Chapters") %>

Chapters diff --git a/app/views/landing/about.html.erb b/app/views/landing/about.html.erb index 7458187d..b3394b54 100644 --- a/app/views/landing/about.html.erb +++ b/app/views/landing/about.html.erb @@ -1,3 +1,4 @@ +<% content_for(:title,"About us") %>
<%= image_tag image_path('workshop.jpg'), class: "pt-20 w-fit h-fit", style: "filter: brightness(40%);" %>
diff --git a/app/views/landing/learn.html.erb b/app/views/landing/learn.html.erb index c4eeb89e..2d707041 100644 --- a/app/views/landing/learn.html.erb +++ b/app/views/landing/learn.html.erb @@ -1,3 +1,4 @@ +<% content_for(:title,"Learning Materials") %>

Featured learning materials diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0215727e..abc62cd0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - ArcPlatform + ArcPlatform <%= " - " + yield(:title) if content_for?(:title)%> <%= csrf_meta_tags %> <%= csp_meta_tag %> From d99a560da11a7a0989422a15d497bb0ff8949cc8 Mon Sep 17 00:00:00 2001 From: AJ-Kulundu Date: Sat, 20 May 2023 12:16:04 +0300 Subject: [PATCH 2/7] Adding dynamic meta descriptions for each page --- app/views/chapters/index.html.erb | 5 +++-- app/views/landing/about.html.erb | 1 + app/views/landing/learn.html.erb | 1 + app/views/layouts/application.html.erb | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index 9d440bf8..039e85f5 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -1,4 +1,5 @@ -<% content_for(:title,"Chapters") %> +<% content_for(:title,"Chapters") %> +<% content_for(:description," A showcase of the different ruby communities spread across the East African region.") %>

Chapters @@ -10,7 +11,7 @@
<%= image_tag chapter.image.attached? ? chapter.image.url : image_path('chapter.jpg'), - alt: 'Local meetups photo', + alt: chapter.name, class: "rounded-lg rounded-tl-2xl" %> diff --git a/app/views/landing/about.html.erb b/app/views/landing/about.html.erb index b3394b54..ec46a3e4 100644 --- a/app/views/landing/about.html.erb +++ b/app/views/landing/about.html.erb @@ -1,4 +1,5 @@ <% content_for(:title,"About us") %> +<% content_for(:description,"The community hosts weekly and monthly meetups in different cities in East Africa. The community brings you Ruby Conference every year with different themes to fill the gap that exist between school and industry and in return helps spur innovation and growth in contribution to global economy") %>
<%= image_tag image_path('workshop.jpg'), class: "pt-20 w-fit h-fit", style: "filter: brightness(40%);" %>
diff --git a/app/views/landing/learn.html.erb b/app/views/landing/learn.html.erb index 2d707041..4743dcb7 100644 --- a/app/views/landing/learn.html.erb +++ b/app/views/landing/learn.html.erb @@ -1,4 +1,5 @@ <% content_for(:title,"Learning Materials") %> +<% content_for(:description,"A list of ruby and ruby on rails learning resources compiled by the ARC community") %>

Featured learning materials diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index abc62cd0..40579ac2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,6 +2,8 @@ ArcPlatform <%= " - " + yield(:title) if content_for?(:title)%> + > + <%= csrf_meta_tags %> <%= csp_meta_tag %> From cc7a2410652d0d2f9e670a98a6698e261ee9ddd9 Mon Sep 17 00:00:00 2001 From: AJ-Kulundu Date: Sat, 20 May 2023 12:29:48 +0300 Subject: [PATCH 3/7] Adding a robots meta tag to specify how a page is crawled --- app/views/chapters/index.html.erb | 1 + app/views/landing/about.html.erb | 1 + app/views/landing/index.html.erb | 1 + app/views/landing/learn.html.erb | 1 + app/views/layouts/application.html.erb | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index 039e85f5..3eb2d91c 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -1,5 +1,6 @@ <% content_for(:title,"Chapters") %> <% content_for(:description," A showcase of the different ruby communities spread across the East African region.") %> +<% content_for(:robots,"index, follow")%>

Chapters diff --git a/app/views/landing/about.html.erb b/app/views/landing/about.html.erb index ec46a3e4..eaf0df04 100644 --- a/app/views/landing/about.html.erb +++ b/app/views/landing/about.html.erb @@ -1,4 +1,5 @@ <% content_for(:title,"About us") %> +<% content_for(:robots,"index, follow")%> <% content_for(:description,"The community hosts weekly and monthly meetups in different cities in East Africa. The community brings you Ruby Conference every year with different themes to fill the gap that exist between school and industry and in return helps spur innovation and growth in contribution to global economy") %>
<%= image_tag image_path('workshop.jpg'), class: "pt-20 w-fit h-fit", style: "filter: brightness(40%);" %> diff --git a/app/views/landing/index.html.erb b/app/views/landing/index.html.erb index 0943e674..5d6e1125 100644 --- a/app/views/landing/index.html.erb +++ b/app/views/landing/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:robots,"index, follow")%> <%= render 'landing/home/intro' %> <% if FeatureFlag.find_by(name: 'events').try(:enabled) %> diff --git a/app/views/landing/learn.html.erb b/app/views/landing/learn.html.erb index 4743dcb7..ba459b95 100644 --- a/app/views/landing/learn.html.erb +++ b/app/views/landing/learn.html.erb @@ -1,5 +1,6 @@ <% content_for(:title,"Learning Materials") %> <% content_for(:description,"A list of ruby and ruby on rails learning resources compiled by the ARC community") %> +<% content_for(:robots,"index, follow")%>

Featured learning materials diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 40579ac2..1faa6be9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,7 +3,7 @@ ArcPlatform <%= " - " + yield(:title) if content_for?(:title)%> > - + > <%= csrf_meta_tags %> <%= csp_meta_tag %> From 25855d8fcf47e2721ff4b59dddace4162a6c1770 Mon Sep 17 00:00:00 2001 From: AJ-Kulundu Date: Sat, 20 May 2023 14:40:41 +0300 Subject: [PATCH 4/7] Using the robots.txt file instead of meta tags --- app/views/chapters/index.html.erb | 1 - app/views/landing/about.html.erb | 1 - app/views/landing/index.html.erb | 1 - app/views/landing/learn.html.erb | 1 - app/views/layouts/application.html.erb | 1 - public/robots.txt | 6 ++++++ 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index 3eb2d91c..039e85f5 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -1,6 +1,5 @@ <% content_for(:title,"Chapters") %> <% content_for(:description," A showcase of the different ruby communities spread across the East African region.") %> -<% content_for(:robots,"index, follow")%>

Chapters diff --git a/app/views/landing/about.html.erb b/app/views/landing/about.html.erb index eaf0df04..ec46a3e4 100644 --- a/app/views/landing/about.html.erb +++ b/app/views/landing/about.html.erb @@ -1,5 +1,4 @@ <% content_for(:title,"About us") %> -<% content_for(:robots,"index, follow")%> <% content_for(:description,"The community hosts weekly and monthly meetups in different cities in East Africa. The community brings you Ruby Conference every year with different themes to fill the gap that exist between school and industry and in return helps spur innovation and growth in contribution to global economy") %>
<%= image_tag image_path('workshop.jpg'), class: "pt-20 w-fit h-fit", style: "filter: brightness(40%);" %> diff --git a/app/views/landing/index.html.erb b/app/views/landing/index.html.erb index 5d6e1125..0943e674 100644 --- a/app/views/landing/index.html.erb +++ b/app/views/landing/index.html.erb @@ -1,4 +1,3 @@ -<% content_for(:robots,"index, follow")%> <%= render 'landing/home/intro' %> <% if FeatureFlag.find_by(name: 'events').try(:enabled) %> diff --git a/app/views/landing/learn.html.erb b/app/views/landing/learn.html.erb index ba459b95..4743dcb7 100644 --- a/app/views/landing/learn.html.erb +++ b/app/views/landing/learn.html.erb @@ -1,6 +1,5 @@ <% content_for(:title,"Learning Materials") %> <% content_for(:description,"A list of ruby and ruby on rails learning resources compiled by the ARC community") %> -<% content_for(:robots,"index, follow")%>

Featured learning materials diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1faa6be9..e34842bd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,7 +3,6 @@ ArcPlatform <%= " - " + yield(:title) if content_for?(:title)%> > - > <%= csrf_meta_tags %> <%= csp_meta_tag %> diff --git a/public/robots.txt b/public/robots.txt index c19f78ab..16af1b7e 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1 +1,7 @@ # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +User-agent: * + +Disallow: /admin + + +Sitemap: https://rubycommunity.africa/sitemap.xml \ No newline at end of file From bd53583f894675bd884dfc4833f40c63bc02d5f7 Mon Sep 17 00:00:00 2001 From: AJ-Kulundu Date: Sat, 20 May 2023 14:46:29 +0300 Subject: [PATCH 5/7] Adding the disallowed webpage URLs for crawlers --- public/robots.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/robots.txt b/public/robots.txt index 16af1b7e..0960d386 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -2,6 +2,11 @@ User-agent: * Disallow: /admin - +Disallow: /chapters/new +Disallow: /chapters/edit +Disallow: /countries/new +Disallow: /countries/edit +Disallow: /projects/new +Disallow: /projects/edit Sitemap: https://rubycommunity.africa/sitemap.xml \ No newline at end of file From 06353391efdb04ad2f8bebade85fe80a07d1d052 Mon Sep 17 00:00:00 2001 From: AJ-Kulundu Date: Sat, 27 May 2023 10:26:14 +0300 Subject: [PATCH 6/7] Installing and creating the sitemap --- Gemfile | 3 +++ Gemfile.lock | 3 +++ config/sitemap.rb | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 config/sitemap.rb diff --git a/Gemfile b/Gemfile index 455567cc..4e34da7a 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,9 @@ gem "redis", "~> 4.0" #Devise 4.0 works with Rails 4.1 onwards. gem 'devise' +#A dynamic sitemap generator gem for the Ruby on Rails framework +gem 'sitemap_generator' + # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] # gem "bcrypt", "~> 3.1.7" diff --git a/Gemfile.lock b/Gemfile.lock index 8977805f..81bffd9e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -304,6 +304,8 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) + sitemap_generator (6.3.0) + builder (~> 3.0) sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -382,6 +384,7 @@ DEPENDENCIES sendgrid-actionmailer (~> 3.2) simple_form (~> 5.1) simplecov + sitemap_generator sprockets-rails stimulus-rails turbo-rails diff --git a/config/sitemap.rb b/config/sitemap.rb new file mode 100644 index 00000000..173424b6 --- /dev/null +++ b/config/sitemap.rb @@ -0,0 +1,27 @@ +# Set the host name for URL creation +SitemapGenerator::Sitemap.default_host = "http://www.example.com" + +SitemapGenerator::Sitemap.create do + # Put links creation logic here. + # + # The root path '/' and sitemap index file are added automatically for you. + # Links are added to the Sitemap in the order they are specified. + # + # Usage: add(path, options={}) + # (default options are used if you don't specify) + # + # Defaults: :priority => 0.5, :changefreq => 'weekly', + # :lastmod => Time.now, :host => default_host + # + # Examples: + # + # Add '/articles' + # + # add articles_path, :priority => 0.7, :changefreq => 'daily' + # + # Add all articles: + # + # Article.find_each do |article| + # add article_path(article), :lastmod => article.updated_at + # end +end From 9039e335c3f51ab0f14680c4221a241c40204886 Mon Sep 17 00:00:00 2001 From: AJ-Kulundu Date: Sat, 27 May 2023 11:01:18 +0300 Subject: [PATCH 7/7] Creating the sitemap and editing the robots.txt --- config/sitemap.rb | 25 ++++++++++++++++++++++++- public/robots.txt | 5 +++++ public/sitemap.xml | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 public/sitemap.xml diff --git a/config/sitemap.rb b/config/sitemap.rb index 173424b6..8be8cda7 100644 --- a/config/sitemap.rb +++ b/config/sitemap.rb @@ -1,5 +1,6 @@ # Set the host name for URL creation -SitemapGenerator::Sitemap.default_host = "http://www.example.com" +SitemapGenerator::Sitemap.default_host = "https://rubycommunity.africa" +SitemapGenerator::Sitemap.compress = false SitemapGenerator::Sitemap.create do # Put links creation logic here. @@ -24,4 +25,26 @@ # Article.find_each do |article| # add article_path(article), :lastmod => article.updated_at # end + + add '/about', + changefreq: 'monthly', + priority: 0.9 + add '/learn', + changefreq: 'monthly', + priority: 0.9 + add '/chapters', + changefreq: 'monthly', + priority: 0.9 + + Chapter.find_each do |chapter| + add chapter_path(chapter), :lastmod => chapter.updated_at + end + + add '/users/sign_up', + changefreq: 'monthly', + priority: 0.8 + + add '/users/sign_in', + changefreq: 'monthly', + priority: 0.8 end diff --git a/public/robots.txt b/public/robots.txt index 0960d386..08e06add 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -8,5 +8,10 @@ Disallow: /countries/new Disallow: /countries/edit Disallow: /projects/new Disallow: /projects/edit +Disallow: /users/ +# Overriding /users route to add the sign in and sign up page to be indexed +Allow: /users/sign_up +Allow: /users/sign_in + Sitemap: https://rubycommunity.africa/sitemap.xml \ No newline at end of file diff --git a/public/sitemap.xml b/public/sitemap.xml new file mode 100644 index 00000000..84ab9b1d --- /dev/null +++ b/public/sitemap.xml @@ -0,0 +1 @@ +https://rubycommunity.africa2023-05-27T10:44:44+03:00weekly1.0https://rubycommunity.africa/about2023-05-27T10:44:44+03:00monthly0.9https://rubycommunity.africa/learn2023-05-27T10:44:44+03:00monthly0.9https://rubycommunity.africa/chapters2023-05-27T10:44:44+03:00monthly0.9 \ No newline at end of file