From aef12bbb2023c33e782b58cbf932106f293867db Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 26 Jul 2025 08:15:37 -0700 Subject: [PATCH] Remove google-analytics This was deprecated in https://github.com/rust-lang/mdBook/pull/1675 in 2021. Closes https://github.com/rust-lang/mdBook/issues/2720 --- crates/mdbook-core/src/config.rs | 7 ------- crates/mdbook-driver/src/mdbook.rs | 10 ---------- .../mdbook-html/front-end/templates/index.hbs | 19 ------------------- .../src/html_handlebars/hbs_renderer.rs | 5 ----- guide/src/format/configuration/renderers.md | 2 -- 5 files changed, 43 deletions(-) diff --git a/crates/mdbook-core/src/config.rs b/crates/mdbook-core/src/config.rs index ef00b143..c40ac4ba 100644 --- a/crates/mdbook-core/src/config.rs +++ b/crates/mdbook-core/src/config.rs @@ -528,8 +528,6 @@ pub struct HtmlConfig { pub mathjax_support: bool, /// Whether to fonts.css and respective font files to the output directory. pub copy_fonts: bool, - /// An optional google analytics code. - pub google_analytics: Option, /// Additional CSS stylesheets to include in the rendered page's ``. pub additional_css: Vec, /// Additional JS scripts to include at the bottom of the rendered page's @@ -593,7 +591,6 @@ impl Default for HtmlConfig { curly_quotes: false, mathjax_support: false, copy_fonts: true, - google_analytics: None, additional_css: Vec::new(), additional_js: Vec::new(), fold: Fold::default(), @@ -811,7 +808,6 @@ mod tests { theme = "./themedir" default-theme = "rust" smart-punctuation = true - google-analytics = "123456" additional-css = ["./foo/bar/baz.css"] git-repository-url = "https://foo.com/" git-repository-icon = "fa-code-fork" @@ -858,7 +854,6 @@ mod tests { }; let html_should_be = HtmlConfig { smart_punctuation: true, - google_analytics: Some(String::from("123456")), additional_css: vec![PathBuf::from("./foo/bar/baz.css")], theme: Some(PathBuf::from("./themedir")), default_theme: Some(String::from("rust")), @@ -1022,7 +1017,6 @@ mod tests { destination = "my-book" # the output files will be generated in `root/my-book` instead of `root/book` theme = "my-theme" smart-punctuation = true - google-analytics = "123456" additional-css = ["custom.css", "custom2.css"] additional-js = ["custom.js"] "#; @@ -1047,7 +1041,6 @@ mod tests { let html_should_be = HtmlConfig { theme: Some(PathBuf::from("my-theme")), smart_punctuation: true, - google_analytics: Some(String::from("123456")), additional_css: vec![PathBuf::from("custom.css"), PathBuf::from("custom2.css")], additional_js: vec![PathBuf::from("custom.js")], ..Default::default() diff --git a/crates/mdbook-driver/src/mdbook.rs b/crates/mdbook-driver/src/mdbook.rs index 533a1d84..0655a6f3 100644 --- a/crates/mdbook-driver/src/mdbook.rs +++ b/crates/mdbook-driver/src/mdbook.rs @@ -65,16 +65,6 @@ impl MDBook { config.update_from_env(); if let Some(html_config) = config.html_config() { - if html_config.google_analytics.is_some() { - warn!( - "The output.html.google-analytics field has been deprecated; \ - it will be removed in a future release.\n\ - Consider placing the appropriate site tag code into the \ - theme/head.hbs file instead.\n\ - The tracking code may be found in the Google Analytics Admin page.\n\ - " - ); - } if html_config.curly_quotes { warn!( "The output.html.curly-quotes field has been renamed to \ diff --git a/crates/mdbook-html/front-end/templates/index.hbs b/crates/mdbook-html/front-end/templates/index.hbs index 1be5bdb0..e4fa64a3 100644 --- a/crates/mdbook-html/front-end/templates/index.hbs +++ b/crates/mdbook-html/front-end/templates/index.hbs @@ -275,25 +275,6 @@ {{/if}} - {{#if google_analytics}} - - - {{/if}} - {{#if playground_line_numbers}}