Skip to content

Commit 4684c70

Browse files
committed
Handle redirects with a custom 404 page instead of using jekyll-redirect-from.
This allows us to redirect entire subtrees instead of just the root. All of the short link redirects can be generated in JavaScript when the website is built, so we longer need to create and check in hundreds of markdown files. Also: - Added badges for the latest and snapshot versions of Javadocs. - Added a redirect from /releases/latest/ to the latest version. - Fixed the whitespaces in the generated HTML files. - Fixed the config so that the website works on local development servers. - Removed some unused files.
1 parent 5c2ea70 commit 4684c70

File tree

792 files changed

+165
-4055
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

792 files changed

+165
-4055
lines changed

Diff for: 404.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
layout: default
3+
title: Page Not Found
4+
redirects:
5+
/api: /releases/snapshot-jre/api/docs
6+
/releases/snapshot/: /releases/snapshot-jre/
7+
/releases/latest/: /releases/{{site.latest_release}}-jre/
8+
---
9+
10+
# 404
11+
12+
The requested URL does not exist.

Diff for: _config.yml

-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Guava
33
subtitle: Google core libraries for Java
44
description: Google core libraries for Java
5-
baseurl: /
65
url: https://guava.dev
76

87
themeColor: red
@@ -18,9 +17,6 @@ exclude:
1817
- vendor
1918
- "*.sh"
2019

21-
plugins:
22-
- jekyll-redirect-from
23-
2420
# Release data
2521
# Do not change! updaterelease.sh automatically updates these fields
2622
latest_release: 33.4.0

Diff for: _includes/footer.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% comment %}
1+
{%- comment -%}
22
Copyright (C) 2018 Google LLC.
33

44
Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,8 +11,8 @@
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
14-
limitations under the License.foobar2
15-
{% endcomment %}
14+
limitations under the License.
15+
{%- endcomment -%}
1616

1717
<footer class="c-footer">
1818
<div class="u-container c-footer__container">

Diff for: _includes/head.html

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% comment %}
1+
{%- comment -%}
22
Copyright (C) 2018 Google LLC.
33

44
Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,8 +11,8 @@
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
14-
limitations under the License.foobar2
15-
{% endcomment %}
14+
limitations under the License.
15+
{%- endcomment -%}
1616

1717
<head>
1818
<meta charset="utf-8">
@@ -22,12 +22,15 @@
2222
<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
2323
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
2424

25+
{%- if page.redirects %}
26+
{% include redirects.html %}
27+
{%- endif %}
28+
2529
<link href='https://fonts.googleapis.com/css?family=Roboto:400,400italic,700|Roboto+Mono:400,500' rel='stylesheet' type='text/css'>
2630
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
27-
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
28-
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
29-
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
30-
{% if site.googleAnalyticsId %}
31+
<link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
32+
<link rel="canonical" href="{{ site.url }}{{ site.baseurl }}{{ page.url | replace: "index.html", "" }}">
33+
{%- if site.googleAnalyticsId %}
3134
<script>
3235
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
3336
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@@ -37,5 +40,5 @@
3740
ga('create', '{{ site.googleAnalyticsId }}', 'auto');
3841
ga('send', 'pageview');
3942
</script>
40-
{% endif %}
43+
{%- endif %}
4144
</head>

Diff for: _includes/navigation.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% comment %}
1+
{%- comment -%}
22
Copyright (C) 2018 Google LLC.
33

44
Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,16 +11,16 @@
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
14-
limitations under the License.foobar2
15-
{% endcomment %}
14+
limitations under the License.
15+
{%- endcomment -%}
1616

1717
<nav class="c-navigation {% if site.fixedNav == 'true' %}is-fixed{% endif %}">
1818
<div class="c-navigation__container u-container">
1919

20-
{% for i in site.nav %}
21-
{% assign url = i.item.url %}
20+
{%- for i in site.nav %}
21+
{%- assign url = i.item.url %}
2222
<a class="c-navigation__item {% if page.url == url %}is-active{% endif %}" href="{{ url | prepend: site.baseurl }}">{{i.item.name}}</a>
23-
{% endfor %}
23+
{%- endfor %}
2424

2525
</div>
2626
</nav>

Diff for: _includes/redirects.html

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{%- comment -%}
2+
Copyright (C) 2025 Google LLC.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
{%- endcomment -%}
16+
17+
<script>
18+
const path = location.pathname.replace('{{ site.baseurl }}', '');
19+
20+
{%- for redirect in page.redirects %}
21+
{%- assign from = redirect[0] %}
22+
{%- assign to = redirect[1] | replace: "{{site.latest_release}}", site.latest_release %}
23+
{%- assign end = from | slice: -1 %}
24+
25+
if (
26+
{%- if end == "/" -%}
27+
path.startsWith('{{ from }}')
28+
{%- else -%}
29+
(path + '/').startsWith('{{ from }}/')
30+
{%- endif -%}
31+
) {
32+
location.pathname = location.pathname.replace('{{ from }}', '{{ to }}');
33+
}
34+
35+
{%- endfor %}
36+
37+
switch (path.replace(/\/(index(\.html)?)?$/, '').toLowerCase()) {
38+
{%- for file in site.static_files %}
39+
{%- if file.extname == ".html"
40+
and file.path contains "/snapshot-jre/api/docs/com/" %}
41+
{%- unless file.basename contains "-"
42+
or file.basename contains "."
43+
or file.path contains "/class-use/" %}
44+
case '/{{ file.basename | downcase }}':
45+
location.pathname = '{{ site.baseurl }}{{ file.path | remove: file.extname }}';
46+
break;
47+
{%- endunless %}
48+
{%- endif %}
49+
{%- endfor %}
50+
}
51+
</script>

Diff for: _includes/social.html

-39
This file was deleted.

Diff for: _layouts/base.html

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% comment %}
1+
{%- comment -%}
22
Copyright (C) 2018 Google LLC.
33

44
Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,16 +12,14 @@
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
15-
{% endcomment %}
15+
{%- endcomment -%}
1616

1717
<!DOCTYPE html>
1818
<html class="t-{{ site.themeColor }}">
19-
{% include head.html %}
20-
<body>
21-
{% include navigation.html %}
22-
23-
{{ content }}
24-
25-
{% include footer.html %}
26-
</body>
19+
{% include head.html %}
20+
<body>
21+
{% include navigation.html %}
22+
{{ content }}
23+
{% include footer.html %}
24+
</body>
2725
</html>

Diff for: _layouts/default.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
layout: base
1717
---
18+
1819
<article class="c-article">
1920
<header class="c-header c-article__header">
2021
<div class="u-container">
@@ -23,6 +24,6 @@ <h1 class="c-header__title">{{ page.title }}</h1>
2324
</header>
2425

2526
<div class="c-article__main">
26-
{{ content }}
27+
{{ content }}
2728
</div>
2829
</article>

Diff for: _layouts/post.html

-18
This file was deleted.

Diff for: _layouts/redirect.html

-11
This file was deleted.

Diff for: api/index.md

-5
This file was deleted.

Diff for: badge/javadoc/latest.svg

+36
Loading

Diff for: badge/javadoc/snapshot.svg

+36
Loading

Diff for: elements/GitHub-Mark-Light-32px.png

-1.53 KB
Binary file not shown.

0 commit comments

Comments
 (0)