Skip to content

Commit bca2dad

Browse files
authored
Forbid migration alias in new posts (#1629)
1 parent 6d8a968 commit bca2dad

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

content/Rust-1.87.0/index.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
path = "2025/05/15/Rust-1.87.0"
33
title = "Announcing Rust 1.87.0 and ten years of Rust!"
44
authors = ["The Rust Release Team"]
5-
aliases = [
6-
"2025/05/15/Rust-1.87.0.html",
7-
"releases/1.87.0",
8-
]
5+
aliases = ["releases/1.87.0"]
96

107
[extra]
118
release = true

content/Rustup-1.28.2.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
path = "2025/05/05/Rustup-1.28.2"
33
title = "Announcing rustup 1.28.2"
44
authors = ["The Rustup Team"]
5-
aliases = ["2025/05/05/Rustup-1.28.2.html"]
65
+++
76

87
The rustup team is happy to announce the release of rustup version 1.28.2.

content/inside-rust/compiler-team-new-members-may-2025.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
path = "inside-rust/2025/05/27/compiler-team-new-members"
33
title = "Announcing five new members of the compiler team"
44
authors = ["davidtwco and wesleywiser"]
5-
aliases = ["inside-rust/2025/05/30/compiler-team-new-members.html"]
65

76
[extra]
87
team = "the compiler team"

content/inside-rust/[email protected]

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
path = "inside-rust/2025/04/22/project-director-update"
33
title = "April 2025 Project Director Update"
44
authors = ["Carol Nichols"]
5-
aliases = ["inside-rust/2025/04/22/project-director-update.html"]
65

76
[extra]
87
team = "Rust Foundation Project Directors"

crates/front_matter/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,31 @@ pub fn normalize(
135135
}
136136
}
137137

138+
let path = front_matter.path.as_str();
139+
let date = path.strip_prefix("inside-rust/").unwrap_or(path);
140+
if date > "2025/04/14" {
141+
// Make sure that posts created after the migration to Zola don't have
142+
// the alias for preserving permalinks.
143+
//
144+
// Blog authors would often copy-paste an old post, reusing the
145+
// boilerplate for a new one. In that process, they'd usually preserve
146+
// that alias as well, probably not knowing what it's for. Technically
147+
// such an alias doesn't hurt much, it's just a redirect that isn't
148+
// referenced anywhere. So these aliases were allowed, preferring not to
149+
// bother blog authors with such unimportant stuff.
150+
//
151+
// However, there was a situation where a blog post was merged with
152+
// the wrong publication date because of this. Shortly before merging,
153+
// the date was updated, but it was accidentally changed in the useless
154+
// alias instead of the authoritative `path` key. Because of this
155+
// footgun, we don't allow creating these new aliases anymore.
156+
//
157+
// Blog authors who copy-paste old boilerplate will run into failed CI
158+
// and have to fix it by removing the alias. It's annoying, but better
159+
// than publishing a post with the wrong publication date.
160+
front_matter.aliases.retain(|a| !a.contains(".html"));
161+
}
162+
138163
if front_matter.extra.team.is_some() ^ front_matter.extra.team_url.is_some() {
139164
bail!("extra.team and extra.team_url must always come in a pair");
140165
}

0 commit comments

Comments
 (0)