Skip to content

Commit c9b6be8

Browse files
authored
Merge pull request #1675 from ehuss/deprecate-ga
Deprecate google-analytics
2 parents 23af80c + c3ff4a5 commit c9b6be8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

guide/src/format/configuration/renderers.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The following configuration options are available:
2121
- **mathjax-support:** Adds support for [MathJax](../mathjax.md). Defaults to
2222
`false`.
2323
- **copy-fonts:** Copies fonts.css and respective font files to the output directory and use them in the default theme. Defaults to `true`.
24-
- **google-analytics:** If you use Google Analytics, this option lets you enable
25-
it by simply specifying your ID in the configuration file.
24+
- **google-analytics:** This field has been deprecated and will be removed in a future release.
25+
Use the `theme/head.hbs` file to add the appropriate Google Analytics code instead.
2626
- **additional-css:** If you need to slightly change the appearance of your book
2727
without overwriting the whole style, you can specify a set of stylesheets that
2828
will be loaded after the default ones where you can surgically change the
@@ -131,7 +131,6 @@ preferred-dark-theme = "navy"
131131
curly-quotes = true
132132
mathjax-support = false
133133
copy-fonts = true
134-
google-analytics = "UA-123456-7"
135134
additional-css = ["custom.css", "custom2.css"]
136135
additional-js = ["custom.js"]
137136
no-section-label = false

src/book/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ impl MDBook {
7070

7171
config.update_from_env();
7272

73+
if config
74+
.html_config()
75+
.map_or(false, |html| html.google_analytics.is_some())
76+
{
77+
warn!(
78+
"The output.html.google-analytics field has been deprecated; \
79+
it will be removed in a future release.\n\
80+
Consider placing the appropriate site tag code into the \
81+
theme/head.hbs file instead.\n\
82+
The tracking code may be found in the Google Analytics Admin page.\n\
83+
"
84+
);
85+
}
86+
7387
if log_enabled!(log::Level::Trace) {
7488
for line in format!("Config: {:#?}", config).lines() {
7589
trace!("{}", line);

0 commit comments

Comments
 (0)