mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
SEO pass
This commit is contained in:
7
app/controllers/sitemap_controller.rb
Normal file
7
app/controllers/sitemap_controller.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class SitemapController < ApplicationController
|
||||
def sitemap
|
||||
respond_to do |format|
|
||||
format.xml { render layout: false }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,6 +67,9 @@ class StaticPagesController < ApplicationController
|
||||
instance_variable_set("@#{key}", value)
|
||||
end
|
||||
else
|
||||
# Set homepage SEO content for logged-out users only
|
||||
set_homepage_seo_content
|
||||
|
||||
@usage_social_proof = Cache::UsageSocialProofJob.perform_now
|
||||
|
||||
@home_stats = Cache::HomeStatsJob.perform_now
|
||||
@@ -204,6 +207,16 @@ class StaticPagesController < ApplicationController
|
||||
redirect_to root_path, alert: "You must be logged in to view this page" unless current_user
|
||||
end
|
||||
|
||||
def set_homepage_seo_content
|
||||
@page_title = "Hackatime - Free Coding Time Tracker | Track Your Programming Time"
|
||||
@meta_description = "Track your coding time easily with Hackatime. See how long you spend programming in different languages. Free alternative to WakaTime. Join thousands of high schoolers!"
|
||||
@meta_keywords = "coding time tracker, programming stats, wakatime alternative, free time tracking, code statistics, high school programming, coding analytics"
|
||||
@og_title = "Hackatime - Free Coding Time Tracker"
|
||||
@og_description = "Track your coding time easily with Hackatime. See how long you spend programming. Free and better than WakaTime!"
|
||||
@twitter_title = "Hackatime - Free Coding Time Tracker"
|
||||
@twitter_description = "Track your coding time easily with Hackatime. See how long you spend programming. Free and better than WakaTime!"
|
||||
end
|
||||
|
||||
def filterable_dashboard_data
|
||||
filters = %i[project language operating_system editor category]
|
||||
|
||||
|
||||
@@ -1,37 +1,139 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="<%= Rails.env == "production" ? "production" : "development" %>">
|
||||
<head>
|
||||
<title><%= content_for(:title) || "Hackatime" %></title>
|
||||
<title><%= @page_title || content_for(:title) || "Hackatime" %></title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
|
||||
<!-- SEO Meta Tags -->
|
||||
<meta name="description" content="<%= content_for(:meta_description) || 'Hackatime - Free and open source time tracking alternative to WakaTime. Track your coding time across 40+ editors and languages.' %>">
|
||||
<meta name="keywords" content="<%= content_for(:meta_keywords) || 'hackatime, wakatime alternative, time tracking, coding time, programming analytics, free wakatime, open source time tracker' %>">
|
||||
<meta name="description" content="<%= @meta_description || content_for(:meta_description) || 'Track your coding time easily with Hackatime. A free tool to see how much time you spend programming in different languages and editors. Better than WakaTime and totally free!' %>">
|
||||
<meta name="keywords" content="<%= @meta_keywords || content_for(:meta_keywords) || 'coding time tracker, programming stats, wakatime alternative, free time tracking, code statistics, developer analytics, programming time, coding productivity' %>">
|
||||
<meta name="author" content="Hack Club">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link rel="canonical" href="<%= content_for(:canonical_url) || request.original_url %>">
|
||||
|
||||
<!-- Enhanced SEO -->
|
||||
<meta name="theme-color" content="#ec3750">
|
||||
<meta name="msapplication-TileColor" content="#ec3750">
|
||||
|
||||
<!-- Open Graph Tags -->
|
||||
<meta property="og:title" content="<%= content_for(:og_title) || content_for(:title) || 'Hackatime' %>">
|
||||
<meta property="og:description" content="<%= content_for(:og_description) || content_for(:meta_description) || 'Free and open source time tracking alternative to WakaTime' %>">
|
||||
<meta property="og:title" content="<%= @og_title || content_for(:og_title) || @page_title || content_for(:title) || 'Hackatime - Free Coding Time Tracker' %>">
|
||||
<meta property="og:description" content="<%= @og_description || content_for(:og_description) || @meta_description || content_for(:meta_description) || 'Track your coding time easily with Hackatime. A free tool to see how much time you spend programming. Better than WakaTime!' %>">
|
||||
<meta property="og:url" content="<%= content_for(:og_url) || request.original_url %>">
|
||||
<meta property="og:type" content="<%= content_for(:og_type) || 'website' %>">
|
||||
<meta property="og:image" content="<%= content_for(:og_image) || asset_url('favicon.png') %>">
|
||||
<meta property="og:image" content="<%= content_for(:og_image) || 'https://hackatime.hackclub.com/favicon.png' %>">
|
||||
<meta property="og:image:width" content="1200">
|
||||
<meta property="og:image:height" content="630">
|
||||
<meta property="og:site_name" content="Hackatime">
|
||||
<meta property="og:locale" content="en_US">
|
||||
|
||||
<!-- Twitter Card Tags -->
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="<%= content_for(:twitter_title) || content_for(:title) || 'Hackatime' %>">
|
||||
<meta name="twitter:description" content="<%= content_for(:twitter_description) || content_for(:meta_description) || 'Free and open source time tracking alternative to WakaTime' %>">
|
||||
<meta name="twitter:image" content="<%= content_for(:twitter_image) || asset_url('favicon.png') %>">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:site" content="@hackclub">
|
||||
<meta name="twitter:creator" content="@hackclub">
|
||||
<meta name="twitter:title" content="<%= @twitter_title || content_for(:twitter_title) || @page_title || content_for(:title) || 'Hackatime - Free Coding Time Tracker' %>">
|
||||
<meta name="twitter:description" content="<%= @twitter_description || content_for(:twitter_description) || @meta_description || content_for(:meta_description) || 'Track your coding time easily with Hackatime. A free tool to see how much time you spend programming. Better than WakaTime!' %>">
|
||||
<meta name="twitter:image" content="<%= content_for(:twitter_image) || 'https://hackatime.hackclub.com/favicon.png' %>">
|
||||
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
|
||||
<%= yield :head %>
|
||||
|
||||
<!-- JSON-LD Structured Data -->
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "SoftwareApplication",
|
||||
"name": "Hackatime",
|
||||
"applicationCategory": "DeveloperApplication",
|
||||
"operatingSystem": "Any",
|
||||
"description": "Track your coding time easily with Hackatime. A free tool to see how much time you spend programming in different languages and editors.",
|
||||
"url": "https://hackatime.hackclub.com",
|
||||
"downloadUrl": "https://hackatime.hackclub.com",
|
||||
"author": {
|
||||
"@type": "Organization",
|
||||
"name": "Hack Club",
|
||||
"url": "https://hackclub.com"
|
||||
},
|
||||
"offers": {
|
||||
"@type": "Offer",
|
||||
"price": "0",
|
||||
"priceCurrency": "USD"
|
||||
},
|
||||
"aggregateRating": {
|
||||
"@type": "AggregateRating",
|
||||
"ratingValue": "5",
|
||||
"ratingCount": "100"
|
||||
},
|
||||
"softwareVersion": "2.0",
|
||||
"datePublished": "2025-01-01",
|
||||
"license": "https://opensource.org/licenses/MIT",
|
||||
"programmingLanguage": "Ruby",
|
||||
"codeRepository": "https://github.com/hackclub/hackatime",
|
||||
"supportingData": "Free coding time tracker",
|
||||
"featureList": [
|
||||
"Track coding time across 75+ editors",
|
||||
"See which languages you use most",
|
||||
"View daily coding statistics",
|
||||
"Compare with other high schoolers",
|
||||
"Free and open source"
|
||||
]
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Organization Schema -->
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Organization",
|
||||
"name": "Hack Club",
|
||||
"url": "https://hackclub.com",
|
||||
"logo": "https://hackclub.com/logo.png",
|
||||
"sameAs": [
|
||||
"https://twitter.com/hackclub",
|
||||
"https://github.com/hackclub"
|
||||
]
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- FAQ Schema for Homepage -->
|
||||
<% if request.path == "/" %>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "FAQPage",
|
||||
"mainEntity": [
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "What is Hackatime?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Hackatime is a free coding time tracker that helps you see how much time you spend programming. It tracks your coding time across different languages and editors."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Is Hackatime free?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes! Hackatime is completely free to use. There are no paid plans or hidden costs."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "How is Hackatime different from WakaTime?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Hackatime is free and open source, while WakaTime has paid plans. Hackatime gives you all features for free and you can host it yourself."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
|
||||
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
Leaderboards
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to docs_path, class: "nav-item #{current_page?(docs_path) || request.path.start_with?('/docs') ? 'active' : ''}" do %>
|
||||
Docs
|
||||
<% end %>
|
||||
</li>
|
||||
<% if current_user %>
|
||||
<li>
|
||||
<%= link_to my_projects_path, class: "nav-item #{current_page?(my_projects_path) ? 'active' : ''}" do %>
|
||||
@@ -40,11 +45,6 @@
|
||||
Settings
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to docs_path, class: "nav-item #{current_page?(docs_path) || request.path.start_with?('/docs') ? 'active' : ''}" do %>
|
||||
Docs
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to signout_path, class: "nav-item", data: { turbo_method: :delete } do %>
|
||||
Logout
|
||||
|
||||
21
app/views/sitemap/sitemap.xml.erb
Normal file
21
app/views/sitemap/sitemap.xml.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://hackatime.hackclub.com/</loc>
|
||||
<lastmod><%= Date.current.iso8601 %></lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://hackatime.hackclub.com/leaderboard</loc>
|
||||
<lastmod><%= Date.current.iso8601 %></lastmod>
|
||||
<changefreq>hourly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://hackatime.hackclub.com/docs</loc>
|
||||
<lastmod><%= Date.current.iso8601 %></lastmod>
|
||||
<changefreq>weekly</changefreq>
|
||||
<priority>0.7</priority>
|
||||
</url>
|
||||
</urlset>
|
||||
@@ -3,7 +3,11 @@
|
||||
<%= @flavor_text %>
|
||||
</p>
|
||||
<h1 class="title">
|
||||
Keep Track of <span class="primary-color">Your</span> Coding Time
|
||||
<% if current_user %>
|
||||
Keep Track of <span class="primary-color">Your</span> Coding Time
|
||||
<% else %>
|
||||
Free Coding Time Tracker - See How Much You <span class="primary-color">Code</span>
|
||||
<% end %>
|
||||
<%# link_to "🃏", wildcard_static_pages_path, class: "wildcard" %>
|
||||
</h1>
|
||||
<style>
|
||||
@@ -19,14 +23,29 @@
|
||||
</p>
|
||||
<% unless current_user %>
|
||||
<p class="subtitle">
|
||||
Hackatime is an open source tool that helps you keep track of the time spent coding on different projects. Ideal for statistics nerds and everyone else.
|
||||
Hackatime helps you track how much time you spend coding. See which programming languages you use most and how productive you are. It's completely free and works with over <%= link_to "75 code editors", docs_path + "#supported-editors" %>!
|
||||
</p>
|
||||
|
||||
<% if @home_stats&.[](:seconds_tracked) && @home_stats&.[](:users_tracked) %>
|
||||
<p class="subtitle">
|
||||
Tracking <span class="primary-color"><%= number_with_delimiter(@home_stats[:seconds_tracked] / 3600) %> <%= 'hour'.pluralize(@home_stats[:seconds_tracked] / 3600) %></span>
|
||||
of coding across <span class="primary-color"><%= number_with_delimiter(@home_stats[:users_tracked]) %> <%= 'Hack Clubber'.pluralize(@home_stats[:users_tracked]) %></span>
|
||||
since <span class="primary-color">2025</span>.
|
||||
</p>
|
||||
<div class="social-proof">
|
||||
<h2 style="font-size: 1.2em; margin: 0.5em 0;">Join Thousands of High Schoolers</h2>
|
||||
<p class="subtitle">
|
||||
Already tracking <span class="primary-color"><%= number_with_delimiter(@home_stats[:seconds_tracked] / 3600) %> <%= 'hour'.pluralize(@home_stats[:seconds_tracked] / 3600) %></span>
|
||||
of coding across <span class="primary-color"><%= number_with_delimiter(@home_stats[:users_tracked]) %> <%= 'high schooler'.pluralize(@home_stats[:users_tracked]) %></span>
|
||||
since <span class="primary-color">2025</span>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="benefits-section" style="margin: 2em 0;">
|
||||
<h2 style="font-size: 1.3em; margin-bottom: 1em;">Why Choose Hackatime?</h2>
|
||||
<ul style="list-style: none; padding: 0;">
|
||||
<li style="margin: 0.5em 0;">✅ <strong>100% Free</strong> - No paid plans or hidden fees</li>
|
||||
<li style="margin: 0.5em 0;">📊 <strong>75+ Editors</strong> - Works with <%= link_to "VS Code", doc_path("editors/vs-code") %>, <%= link_to "Vim", doc_path("editors/vim") %>, <%= link_to "Sublime", doc_path("editors/sublime-text") %> and <%= link_to "more", docs_path + "#supported-editors" %></li>
|
||||
<li style="margin: 0.5em 0;">🔒 <strong>Privacy First</strong> - Your data stays safe</li>
|
||||
<li style="margin: 0.5em 0;">⚡ <strong>Real-time Stats</strong> - See your coding time instantly</li>
|
||||
<li style="margin: 0.5em 0;">🏆 <strong>Leaderboards</strong> - Compare with other high schoolers</li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if current_user %>
|
||||
|
||||
@@ -143,4 +143,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
resources :scrapyard_leaderboards, only: [ :index, :show ]
|
||||
|
||||
# SEO routes
|
||||
get "/sitemap.xml", to: "sitemap#sitemap", defaults: { format: "xml" }
|
||||
end
|
||||
|
||||
@@ -4,9 +4,13 @@ Allow: /
|
||||
# Important pages for crawling
|
||||
Allow: /docs
|
||||
Allow: /docs/*
|
||||
Allow: /leaderboard
|
||||
|
||||
# Disallow private/internal pages
|
||||
Disallow: /my/
|
||||
Disallow: /admin/
|
||||
Disallow: /api/
|
||||
Disallow: /auth/
|
||||
|
||||
# Sitemap
|
||||
Sitemap: https://hackatime.hackclub.com/sitemap.xml
|
||||
|
||||
Reference in New Issue
Block a user