Skip to content

Commit 7b52aea

Browse files
BaseMaxCopilot
andauthored
Adding SEO tags, adding sitemap (#494)
* Adding SEO tags, adding sitemap * Apply AI feedbacks * Fix prek run -a * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * add escape * update * Fix ai feedbacks * Adding lastmod to sitemap * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 485da4d commit 7b52aea

8 files changed

Lines changed: 162 additions & 3 deletions

File tree

.eleventy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ const yaml = require("js-yaml");
22

33
module.exports = (eleventyConfig) => {
44
eleventyConfig.addShortcode("currentYear", () => new Date().getFullYear());
5+
eleventyConfig.addFilter("safeJsonLd", (value) => {
6+
const json = JSON.stringify(value) ?? "null";
7+
return json.replace(/<\//g, "<\\/");
8+
});
59
// Add this line to copy your external assets
610
eleventyConfig.addPassthroughCopy("src/assets");
711
// 1. Recognize YAML as a template format

src/_data/site.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
name: "NextCommunity Developer Directory",
3+
author: "NextCommunity",
4+
url: "https://nextcommunity.github.io",
5+
locale: "en_US",
6+
themeColor: "#2563eb",
7+
twitterCard: "summary_large_image",
8+
defaultImage: "/assets/img/next.jpeg",
9+
};

src/_includes/bio.njk

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,29 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>{{ name }} | {{ role }}</title>
6+
{% set seoBioDescription = bio
7+
and (bio
8+
| replace('\r', ' ')
9+
| replace('\n', ' ')
10+
| replace('\t', ' ')
11+
| replace('"', "'")
12+
| trim
13+
| truncate(160))
14+
or "" %}
15+
{% set seo = {
16+
title: name + " | " + role + " | NextCommunity",
17+
description: (seoBioDescription or ("Explore " + name + "'s developer profile, skills, and social links on NextCommunity.")),
18+
keywords: "developer profile, " + name + ", " + role + ", github profile, software developer portfolio",
19+
type: "profile",
20+
image: site.defaultImage,
21+
person: {
22+
name: name,
23+
role: role,
24+
github: github,
25+
linkedin: linkedin
26+
}
27+
} %}
28+
{% include "seo-meta.njk" %}
729
<script src="https://cdn.tailwindcss.com"></script>
830
<link rel="stylesheet" href="/assets/css/style.css">
931
</head>

src/_includes/seo-meta.njk

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{% set siteUrl = site.url or "https://nextcommunity.github.io" %}
2+
{% set pagePath = page.url or "/" %}
3+
{% set canonicalUrl = siteUrl + pagePath %}
4+
{% set seoTitle = seo.title or (site.name + " | Open Source Profiles") %}
5+
{% set seoDescription = seo.description or "Discover and connect with open-source developers in the NextCommunity global talent directory." %}
6+
{% set seoKeywords = seo.keywords or "developer directory, open source developers, software engineers, github profiles, tech community" %}
7+
{% set seoType = seo.type or "website" %}
8+
{% set imagePath = seo.image or site.defaultImage %}
9+
{% if imagePath and imagePath[0] == "/" %}
10+
{% set imageUrl = siteUrl + imagePath %}
11+
{% else %}
12+
{% set imageUrl = imagePath %}
13+
{% endif %}
14+
15+
<title>{{ seoTitle | escape }}</title>
16+
<meta name="description" content="{{ seoDescription | escape }}">
17+
<meta name="keywords" content="{{ seoKeywords | escape }}">
18+
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1">
19+
<meta name="author" content="{{ (site.author or 'NextCommunity') | escape }}">
20+
<meta name="theme-color" content="{{ (site.themeColor or '#2563eb') | escape }}">
21+
<link rel="canonical" href="{{ canonicalUrl | escape }}">
22+
23+
<meta property="og:locale" content="{{ (site.locale or 'en_US') | escape }}">
24+
<meta property="og:type" content="{{ seoType | escape }}">
25+
<meta property="og:site_name" content="{{ (site.name or 'NextCommunity Developer Directory') | escape }}">
26+
<meta property="og:title" content="{{ seoTitle | escape }}">
27+
<meta property="og:description" content="{{ seoDescription | escape }}">
28+
<meta property="og:url" content="{{ canonicalUrl | escape }}">
29+
<meta property="og:image" content="{{ imageUrl | escape }}">
30+
<meta property="og:image:alt" content="{{ seoTitle | escape }}">
31+
32+
<meta name="twitter:card" content="{{ (site.twitterCard or 'summary_large_image') | escape }}">
33+
<meta name="twitter:title" content="{{ seoTitle | escape }}">
34+
<meta name="twitter:description" content="{{ seoDescription | escape }}">
35+
<meta name="twitter:image" content="{{ imageUrl | escape }}">
36+
37+
<script type="application/ld+json">
38+
{
39+
"@context": "https://schema.org",
40+
"@type": "WebSite",
41+
"name": {{ (site.name or 'NextCommunity Developer Directory') | safeJsonLd | safe }},
42+
"url": {{ siteUrl | safeJsonLd | safe }},
43+
"inLanguage": {{ ((site.locale or 'en_US') | replace('_', '-')) | safeJsonLd | safe }},
44+
"publisher": {
45+
"@type": "Organization",
46+
"name": "NextCommunity",
47+
"url": {{ siteUrl | safeJsonLd | safe }}
48+
}
49+
}
50+
</script>
51+
52+
<script type="application/ld+json">
53+
{
54+
"@context": "https://schema.org",
55+
"@type": "WebPage",
56+
"name": {{ seoTitle | safeJsonLd | safe }},
57+
"description": {{ seoDescription | safeJsonLd | safe }},
58+
"url": {{ canonicalUrl | safeJsonLd | safe }},
59+
"isPartOf": {
60+
"@type": "WebSite",
61+
"name": {{ (site.name or 'NextCommunity Developer Directory') | safeJsonLd | safe }},
62+
"url": {{ siteUrl | safeJsonLd | safe }}
63+
},
64+
"primaryImageOfPage": {
65+
"@type": "ImageObject",
66+
"url": {{ imageUrl | safeJsonLd | safe }}
67+
}
68+
}
69+
</script>
70+
71+
{% if seo.person %}
72+
<script type="application/ld+json">
73+
{
74+
"@context": "https://schema.org",
75+
"@type": "Person",
76+
"name": {{ seo.person.name | safeJsonLd | safe }},
77+
"jobTitle": {{ seo.person.role | safeJsonLd | safe }},
78+
"url": {{ canonicalUrl | safeJsonLd | safe }},
79+
"sameAs": [
80+
{% if seo.person.github %}{{ ("https://github.com/" + seo.person.github) | safeJsonLd | safe }}{% endif %}
81+
{% if seo.person.github and seo.person.linkedin %},{% endif %}
82+
{% if seo.person.linkedin %}{{ seo.person.linkedin | safeJsonLd | safe }}{% endif %}
83+
]
84+
}
85+
</script>
86+
{% endif %}

src/games.njk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ permalink: /games/
77
<head>
88
<meta charset="UTF-8">
99
<meta name="viewport" content="width=device-width, initial-scale=1.0">
10-
<title>Arcade | Developer Directory</title>
10+
{% set seo = {
11+
title: "Developer Arcade | Coding Games, XP, and Achievements",
12+
description: "Play coding mini-games, earn XP, and unlock achievements in the NextCommunity Developer Arcade.",
13+
keywords: "developer games, coding arcade, programming mini games, developer xp, gamified coding",
14+
type: "website",
15+
image: "/assets/img/next.jpeg"
16+
} %}
17+
{% include "seo-meta.njk" %}
1118
<script src="https://cdn.tailwindcss.com"></script>
1219
<link rel="stylesheet" href="/assets/css/style.css">
1320
</head>

src/index.njk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ layout: false
66
<head>
77
<meta charset="UTF-8">
88
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9-
<title>Developer Directory</title>
9+
{% set seo = {
10+
title: "NextCommunity Developer Directory | Discover Open-Source Talent",
11+
description: "Explore developer profiles from around the world, discover skills, and connect with open-source contributors in the NextCommunity directory.",
12+
keywords: "developer directory, open source developers, software engineers, github developers, developer community, global tech talent",
13+
type: "website",
14+
image: "/assets/img/next.jpeg"
15+
} %}
16+
{% include "seo-meta.njk" %}
1017
<link rel="stylesheet" href="/assets/css/tailwind.css">
1118
<link rel="stylesheet" href="/assets/css/style.css">
1219
</head>

src/robots.njk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
permalink: /robots.txt
3+
eleventyExcludeFromCollections: true
4+
---
5+
User-agent: *
6+
Allow: /
7+
Sitemap: {{ site.url }}/sitemap.xml

src/sitemap.njk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
permalink: /sitemap.xml
3+
eleventyExcludeFromCollections: true
4+
---
5+
<?xml version="1.0" encoding="UTF-8"?>
6+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
7+
{% for entry in collections.all %}
8+
{% if entry.url and entry.url != "/404.html" %}
9+
<url>
10+
<loc>{{ site.url | escape }}{{ entry.url | escape }}</loc>
11+
{% if entry.date %}
12+
<lastmod>{{ entry.date.toISOString().split('T')[0] }}</lastmod>
13+
{% endif %}
14+
</url>
15+
{% endif %}
16+
{% endfor %}
17+
</urlset>

0 commit comments

Comments
 (0)