Skip to content

Commit aca61ab

Browse files
committed
Improved site SEO
- Added sitemap XML generated using nunjucks - Added author, opengraph, and twitter meta tags in _head.html - Added schema.org structured data in _head.html - Changed canonical url to jiwonac.github.io - Added robots.txt pointing to sitemap
1 parent 75e4bee commit aca61ab

8 files changed

Lines changed: 132 additions & 6 deletions

File tree

.eleventy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports = function(eleventyConfig) {
3838
eleventyConfig.addPassthroughCopy("src/_scripts/rough-cards.js");
3939
eleventyConfig.addPassthroughCopy("src/_scripts/microblog-cards.js");
4040
eleventyConfig.addPassthroughCopy("src/favicon.ico");
41+
eleventyConfig.addPassthroughCopy("src/robots.txt");
4142
eleventyConfig.addPassthroughCopy("src/assets");
4243
eleventyConfig.addPassthroughCopy("src/admin");
4344

src/_data/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"title": "Jiwon's Alcove",
33
"description": "Internet den of a computer science PhD student.",
44
"name": "Jiwon Chang",
5-
"baseURL": "https://jiwonc.net/",
5+
"baseURL": "https://jiwonac.github.io",
66
"language": "en-us",
77
"smalllinks": [
88
{

src/_includes/_head.html

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,39 @@
22
<meta charset="utf-8">
33
<meta name="viewport" content="width=device-width, initial-scale=1.0">
44
<title>{% if title %}{{ title }} | {% endif %}{{ metadata.title }}</title>
5-
<meta name="description" content="{{ metadata.description }}">
5+
6+
<!-- SEO Meta Tags -->
7+
{% assign pageDescription = blurb | default: metadata.description %}
8+
{% assign pageTitle = title | default: metadata.title %}
9+
{% assign canonicalUrl = metadata.baseURL | append: page.url %}
10+
{% if image %}{% assign imageUrl = metadata.baseURL | append: image %}{% endif %}
11+
<meta name="description" content="{{ pageDescription }}">
12+
<link rel="canonical" href="{{ canonicalUrl }}">
13+
<meta name="author" content="{{ metadata.name }}">
614
<meta name="google-site-verification" content="6TWQ5Bn6LQn9UJ3mgt1nIDIsdvIsPOilhHuWvy5S5kY" />
715

16+
<!-- Open Graph -->
17+
<meta property="og:title" content="{{ pageTitle }}">
18+
<meta property="og:description" content="{{ pageDescription }}">
19+
<meta property="og:url" content="{{ canonicalUrl }}">
20+
<meta property="og:site_name" content="{{ metadata.title }}">
21+
<meta property="og:locale" content="{{ metadata.language | replace: '-', '_' }}">
22+
{% if tags contains 'blog' or tags contains 'research' or tags contains 'writings' or tags contains 'microblog' %}<meta property="og:type" content="article">
23+
{% if date %}<meta property="article:published_time" content="{{ date | date: '%Y-%m-%dT%H:%M:%S+00:00' }}">{% endif %}
24+
<meta property="article:author" content="{{ metadata.name }}">
25+
{% else %}<meta property="og:type" content="website">
26+
{% endif %}{% if image %}<meta property="og:image" content="{{ imageUrl }}">
27+
{% if alt %}<meta property="og:image:alt" content="{{ alt }}">{% endif %}
28+
{% endif %}
29+
30+
<!-- Twitter Card -->
31+
<meta name="twitter:card" content="summary">
32+
<meta name="twitter:title" content="{{ pageTitle }}">
33+
<meta name="twitter:description" content="{{ pageDescription }}">
34+
{% if image %}<meta name="twitter:image" content="{{ imageUrl }}">
35+
{% if alt %}<meta name="twitter:image:alt" content="{{ alt }}">{% endif %}
36+
{% endif %}
37+
838
<!-- Theme init: must load synchronously before CSS to prevent flash -->
939
<script src="/_scripts/theme-init.js"></script>
1040

@@ -31,4 +61,60 @@
3161
};
3262
</script>
3363

34-
</head>
64+
<!-- JSON-LD Structured Data -->
65+
<script type="application/ld+json">
66+
{
67+
"@context": "https://schema.org",
68+
"@type": "WebSite",
69+
"name": "{{ metadata.title }}",
70+
"url": "{{ metadata.baseURL }}",
71+
"description": "{{ metadata.description }}",
72+
"author": {
73+
"@type": "Person",
74+
"name": "{{ metadata.name }}",
75+
"url": "{{ metadata.baseURL }}"
76+
}
77+
}
78+
</script>
79+
{% if tags contains 'blog' or tags contains 'research' or tags contains 'writings' %}
80+
<script type="application/ld+json">
81+
{
82+
"@context": "https://schema.org",
83+
"@type": "Article",
84+
"headline": "{{ title }}",
85+
"description": "{{ pageDescription }}",
86+
"url": "{{ canonicalUrl }}",
87+
"datePublished": "{{ date | date: '%Y-%m-%dT%H:%M:%S+00:00' }}",
88+
"author": {
89+
"@type": "Person",
90+
"name": "{{ metadata.name }}",
91+
"url": "{{ metadata.baseURL }}"
92+
},
93+
"publisher": {
94+
"@type": "Person",
95+
"name": "{{ metadata.name }}",
96+
"url": "{{ metadata.baseURL }}"
97+
}{% if image %},
98+
"image": "{{ imageUrl }}"{% endif %}
99+
}
100+
</script>
101+
{% elsif tags contains 'microblog' %}
102+
<script type="application/ld+json">
103+
{
104+
"@context": "https://schema.org",
105+
"@type": "BlogPosting",
106+
"headline": "{{ title }}",
107+
"description": "{{ pageDescription }}",
108+
"url": "{{ canonicalUrl }}",
109+
"datePublished": "{{ date | date: '%Y-%m-%dT%H:%M:%S+00:00' }}",
110+
"author": {
111+
"@type": "Person",
112+
"name": "{{ metadata.name }}",
113+
"url": "{{ metadata.baseURL }}"
114+
}{% if image %},
115+
"image": "{{ imageUrl }}"{% endif %}
116+
}
117+
</script>
118+
{% endif %}
119+
120+
</head>

src/blog/feed.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"title": "Jiwon's Alcove",
88
"subtitle": "Musings on computer science and life.",
99
"language": "en",
10-
"url": "https://jiwonc.net/",
10+
"url": "https://jiwonac.github.io",
1111
"author": {
1212
"name": "Jiwon Chang"
1313
}

src/feed.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"title": "Jiwon's Alcove",
88
"subtitle": "Musings on computer science and life.",
99
"language": "en",
10-
"url": "https://jiwonc.net/",
10+
"url": "https://jiwonac.github.io",
1111
"author": {
1212
"name": "Jiwon Chang"
1313
}

src/microblog/feed.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"title": "Jiwon's Alcove",
88
"subtitle": "Musings on computer science and life.",
99
"language": "en",
10-
"url": "https://jiwonc.net/",
10+
"url": "https://jiwonac.github.io",
1111
"author": {
1212
"name": "Jiwon Chang"
1313
}

src/robots.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
User-agent: *
2+
Allow: /
3+
4+
Sitemap: https://jiwonac.github.io/sitemap.xml

src/sitemap.njk

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---json
2+
{
3+
"layout": "",
4+
"permalink": "sitemap.xml",
5+
"eleventyExcludeFromCollections": true
6+
}
7+
---
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
10+
<url>
11+
<loc>{{ metadata.baseURL }}</loc>
12+
<changefreq>weekly</changefreq>
13+
<priority>1.0</priority>
14+
</url>
15+
{%- for page in collections.all %}
16+
{%- if page.url and page.url != "/" %}
17+
<url>
18+
<loc>{{ page.url | absoluteUrl(metadata.baseURL) }}</loc>
19+
{%- if page.date %}
20+
<lastmod>{{ page.date | dateToRfc3339 | truncate(10, true, "") }}</lastmod>
21+
{%- endif %}
22+
{%- if page.data.tags and ('blog' in page.data.tags or 'research' in page.data.tags or 'writings' in page.data.tags) %}
23+
<changefreq>yearly</changefreq>
24+
<priority>0.8</priority>
25+
{%- elif page.data.tags and 'microblog' in page.data.tags %}
26+
<changefreq>yearly</changefreq>
27+
<priority>0.6</priority>
28+
{%- else %}
29+
<changefreq>monthly</changefreq>
30+
<priority>0.7</priority>
31+
{%- endif %}
32+
</url>
33+
{%- endif %}
34+
{%- endfor %}
35+
</urlset>

0 commit comments

Comments
 (0)