From 5163c5ab75c3f2160745ec838224dab3ccf73f71 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 8 May 2019 00:32:43 +0200 Subject: [PATCH] Don't let robots index the print.html (#844) --- src/theme/index.hbs | 4 ++++ tests/rendered_output.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/theme/index.hbs b/src/theme/index.hbs index aaab4053..5e0d7013 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -4,6 +4,10 @@ {{ title }} + {{#if is_print }} + + {{/if}} + diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 3c9632a1..2d679e4d 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -415,6 +415,20 @@ fn theme_dir_overrides_work_correctly() { dummy_book::assert_contains_strings(built_index, &["This is a modified index.hbs!"]); } + +#[test] +fn no_index_for_print_html() { + let temp = DummyBook::new().build().unwrap(); + let md = MDBook::load(temp.path()).unwrap(); + md.build().unwrap(); + + let print_html = temp.path().join("book/print.html"); + assert_contains_strings(print_html, &[r##"noindex"##]); + + let index_html = temp.path().join("book/index.html"); + assert_doesnt_contain_strings(index_html, &[r##"noindex"##]); +} + #[cfg(feature = "search")] mod search { extern crate serde_json;