Skip to content

Commit 040865a

Browse files
committed
Port similar Google SEO fix
1 parent 38d775d commit 040865a

File tree

7 files changed

+310
-67
lines changed

7 files changed

+310
-67
lines changed

_config.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ defaults:
126126
path: _posts/papers
127127
type: posts
128128
values:
129-
layout: single
129+
layout: publication
130130
classes:
131131
- wide
132132
author_profile: true
@@ -142,6 +142,16 @@ defaults:
142142
- no-sidebar
143143
author_profile: false
144144

145+
# _pages/profiles
146+
- scope:
147+
path: "_pages/profiles"
148+
type: pages
149+
values:
150+
layout: profile
151+
classes:
152+
- wide
153+
- no-sidebar
154+
author_profile: true
145155

146156
# _projects
147157
- scope:
@@ -154,9 +164,6 @@ defaults:
154164
author_profile: false
155165
share: true
156166

157-
158-
159-
160167
category_archive:
161168
type: liquid
162169
path: /categories/

_includes/breadcrumbs-schema.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script type="application/ld+json">
2+
{
3+
"@context": "https://schema.org",
4+
"@type": "BreadcrumbList",
5+
"itemListElement": [
6+
{
7+
"@type": "ListItem",
8+
"position": 1,
9+
"name": "Home",
10+
"item": "{{ site.url }}"
11+
}
12+
{% if page.layout == 'publication' %},
13+
{
14+
"@type": "ListItem",
15+
"position": 2,
16+
"name": "Publications",
17+
"item": "{{ site.url }}/publications/"
18+
},
19+
{
20+
"@type": "ListItem",
21+
"position": 3,
22+
"name": "{{ page.title | truncate: 60 }}",
23+
"item": "{{ site.url }}{{ page.url }}"
24+
}
25+
{% elsif page.layout == 'profile' %},
26+
{
27+
"@type": "ListItem",
28+
"position": 2,
29+
"name": "People",
30+
"item": "{{ site.url }}/people/"
31+
},
32+
{
33+
"@type": "ListItem",
34+
"position": 3,
35+
"name": "{{ page.title }}",
36+
"item": "{{ site.url }}{{ page.url }}"
37+
}
38+
{% endif %}
39+
]
40+
}
41+
</script>

_includes/head/custom.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<!-- Add favicon -->
22
<link rel="icon" type="image/png" href="{{ site.baseurl }}/assets/images/logo/favicon.png">
33

4+
<!-- SEO meta tags -->
5+
<meta name="author" content="{% if page.names %}{{ page.names }}{% else %}{{ page.title }}{% endif %}">
6+
<meta name="description"
7+
content="{% if page.abstract %}{{ page.abstract | strip_html | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
8+
9+
<!-- Open Graph and Twitter Card data -->
10+
<meta property="og:type" content="{% if page.layout == 'publication' %}article{% else %}profile{% endif %}">
11+
<meta property="og:locale" content="en_US">
12+
<meta property="og:site_name" content="{{ site.title }}">
13+
<meta property="og:title" content="{{ page.title }}">
14+
<meta property="og:description"
15+
content="{% if page.abstract %}{{ page.abstract | strip_html | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
16+
{% if page.openAccessPdf.url %}
17+
<meta property="og:url" content="{{ page.openAccessPdf.url }}">{% endif %}
18+
419
{% if site.dark_theme_css %}
520
<!-- Dark Mode -->
621
<link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}" id="theme-css">
@@ -81,5 +96,33 @@
8196
});
8297
</script>
8398

99+
<!-- Custom CSS for publication and profile pages -->
100+
<style>
101+
.publication-meta {
102+
margin-bottom: 2em;
103+
padding: 1em;
104+
background: #f8f9fa;
105+
border-radius: 4px;
106+
}
107+
108+
.profile-header {
109+
display: flex;
110+
align-items: center;
111+
gap: 2em;
112+
margin-bottom: 2em;
113+
}
114+
115+
.profile-header img {
116+
border-radius: 50%;
117+
max-width: 200px;
118+
}
119+
120+
@media (max-width: 768px) {
121+
.profile-header {
122+
flex-direction: column;
123+
text-align: center;
124+
}
125+
}
126+
</style>
84127

85128
{% endif %}

_includes/posts-publication.html

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,56 @@
11
{% assign posts = site.categories[include.taxonomy] | where_exp: "item", "item.hidden != true" %}
2-
{% assign group_by_year = include.group_by_year | default: true %}
32
{% if include.author %}
4-
{% assign posts = posts | where_exp: "post", "post.names contains include.author" %}
5-
6-
{% comment %}
7-
Ideally we want to use:
8-
{% assign posts = posts | where_exp: "post", "post.names contains include.author or post.author == include.author" %}
9-
10-
However it is not currently supported by Jekyll 3.9.2, which is what is being used by the GitHub Pages Gem. However,
11-
the gem maintainers are currently working on upgrading jekyll to 4.x, which supports binary operator for where_exp:
12-
13-
https://github.com/github/pages-gem/issues/651#issuecomment-1156978042
14-
{% endcomment %}
15-
3+
{% assign posts = posts | where_exp: "post", "post.names contains include.author" %}
164
{% endif %}
175

18-
196
{% if include.disable_group_by_year == true %}
7+
<div class="entries-{{ entries_layout | default: 'list' }}">
208
{% for post in posts %}
21-
{%- include display-publications.html %}
9+
{%- include display-publications.html %}
2210
{% endfor %}
11+
</div>
2312
{% else %}
13+
{% assign postsByYear = posts | group_by_exp: 'post', 'post.date | default: "9999-01-01" | date: "%Y"' %}
2414

25-
{% assign postsByYear = posts | group_by_exp: 'post', 'post.date | date: "%Y"' %}
26-
15+
{% if postsByYear.size > 0 %}
2716
{% unless include.hide_years_dropdown == true %}
28-
<details>
17+
<details class="publications-years">
2918
<summary>Show years</summary>
30-
<ul class="taxonomy__index">
31-
{% for year in postsByYear %}
32-
<li>
33-
<a href="#{{ year.name }}">
34-
<strong>{{ year.name }}</strong> <span class="taxonomy__count">{{ year.items | size }}</span>
35-
</a>
36-
</li>
19+
<div class="taxonomy__index">
20+
{% assign sortedYears = postsByYear | sort: 'name' | reverse %}
21+
{% for year in sortedYears %}
22+
{% if year.name == "9999" %}
23+
{% assign yearName = "None" %}
24+
{% else %}
25+
{% assign yearName = year.name %}
26+
{% endif %}
27+
<a href="#{{ yearName | slugify }}" class="year-link">
28+
<strong>{{ yearName }}</strong> <span class="taxonomy__count">{{ year.items | size }}</span>
29+
</a>
3730
{% endfor %}
38-
</ul>
31+
</div>
3932
</details>
4033
{% endunless %}
4134

42-
{% for year in postsByYear %}
43-
<section id="{{ year.name }}" class="taxonomy__section">
44-
<h3>{{ year.name }}</h3>
45-
<div class="entries-{{ entries_layout }}">
46-
{% for post in year.items %}
47-
{%- include display-publications.html %}
48-
{% endfor %}
49-
</div>
50-
<a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} &uarr;</a>
51-
</section>
52-
{% endfor %}
35+
{% assign sortedYears = postsByYear | sort: 'name' | reverse %}
36+
{% for year in sortedYears %}
37+
{% if year.name == "9999" %}
38+
{% assign yearName = "None" %}
39+
{% else %}
40+
{% assign yearName = year.name %}
41+
{% endif %}
5342

43+
<section id="{{ yearName | slugify }}" class="taxonomy__section">
44+
<h3 class="archive__subtitle">{{ yearName }}</h3>
45+
<div class="entries-{{ entries_layout | default: 'list' }}">
46+
{% assign yearItems = year.items | sort: 'date' | reverse %}
47+
{% for post in yearItems %}
48+
{%- include display-publications.html %}
49+
{% endfor %}
50+
</div>
51+
<a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }}
52+
&uarr;</a>
53+
</section>
54+
{% endfor %}
55+
{% endif %}
5456
{% endif %}

_layouts/profile.html

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,66 @@
11
---
2-
layout: default
2+
layout: archive
33
---
44

5+
{% include breadcrumbs-schema.html %}
6+
7+
<script type="application/ld+json">
8+
{
9+
"@context": "https://schema.org",
10+
"@type": "Person",
11+
"name": "{{ page.title }}",
12+
"url": "{{ site.url }}{{ page.permalink }}",
13+
{% assign author = site.data.authors[page.title] %}
14+
{% if author.avatar %}
15+
"image": "{{ site.url }}{{ author.avatar }}",
16+
{% endif %}
17+
{% if author.bio %}
18+
"description": {{ author.bio | jsonify }} ,
19+
{% endif %}
20+
{% if author.googleScholar %}
21+
"sameAs": [
22+
"{{ author.googleScholar }}"
23+
{% if author.twitter %}, "{{ author.twitter }}"{% endif %}
24+
{% if author.linkedin %}, "{{ author.linkedin }}"{% endif %}
25+
{% if author.github %}, "https://github.com/{{ author.github }}"{% endif %}
26+
],
27+
{% endif %}
28+
"affiliation": {
29+
"@type": "Organization",
30+
"name": "Complex Data Lab, McGill University & Mila"
31+
}
32+
}
33+
</script>
34+
535
{% if page.header.overlay_color or page.header.overlay_image or page.header.image %}
6-
{% include page__hero.html %}
36+
{% include page__hero.html %}
737
{% elsif page.header.video.id and page.header.video.provider %}
8-
{% include page__hero_video.html %}
38+
{% include page__hero_video.html %}
939
{% endif %}
1040

1141
{% if page.url != "/" and site.breadcrumbs %}
12-
{% unless paginator %}
13-
{% include breadcrumbs.html %}
14-
{% endunless %}
42+
{% unless paginator %}
43+
{% include breadcrumbs.html %}
44+
{% endunless %}
1545
{% endif %}
1646

1747
<div id="main" role="main">
1848
{% include sidebar.html %}
1949

50+
<div class="profile-header">
51+
{% assign author = site.data.authors[page.title] %}
52+
{% if author.avatar %}
53+
<img src="{{ author.avatar | relative_url }}" alt="{{ page.title }}">
54+
{% endif %}
55+
<div class="profile-info">
56+
<h1>{{ page.title }}</h1>
57+
{% if author.bio %}<p>{{ author.bio }}</p>{% endif %}
58+
</div>
59+
</div>
60+
2061
<div class="archive">
2162
{% unless page.header.overlay_color or page.header.overlay_image %}
22-
<!-- <h1 id="page-title" class="page__title">{{ page.title }}</h1> -->
63+
<!-- <h1 id="page-title" class="page__title">{{ page.title }}</h1> -->
2364
{% endunless %}
2465
{{ content }}
2566
</div>

_layouts/publication.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
---
2-
layout: archive
2+
layout: single
33
---
44

5+
{% include breadcrumbs-schema.html %}
6+
7+
<script type="application/ld+json">
8+
{
9+
"@context": "https://schema.org",
10+
"@type": "ScholarlyArticle",
11+
"headline": "{{ page.title }}",
12+
"author": [
13+
{% assign authors = page.names | split: ", " %}
14+
{% for author in authors %}
15+
{
16+
"@type": "Person",
17+
"name": "{{ author }}"
18+
}{% unless forloop.last %},{% endunless %}
19+
{% endfor %}
20+
],
21+
"datePublished": "{{ page.name | slice: 0,10 }}",
22+
"publisher": "{{ page.venue }}",
23+
{% if page.openAccessPdf.url %}
24+
"url": "{{ page.openAccessPdf.url }}",
25+
{% endif %}
26+
{% if page.abstract %}
27+
"abstract": {{ page.abstract | jsonify }},
28+
{% endif %}
29+
{% if page.tags %}
30+
"keywords": {{ page.tags | jsonify }},
31+
{% endif %}
32+
"isAccessibleForFree": {% if page.openAccessPdf.status == "OPEN" %}true{% else %}false{% endif %}
33+
}
34+
</script>
35+
536
{{ content }}
637

738
<div>

0 commit comments

Comments
 (0)