diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs
index 0333999a..f76cb8eb 100644
--- a/src/renderer/html_handlebars/hbs_renderer.rs
+++ b/src/renderer/html_handlebars/hbs_renderer.rs
@@ -51,9 +51,17 @@ impl HtmlHandlebars {
io::Error::new(io::ErrorKind::Other, "Could not convert path to str")
})?;
+ // Non-lexical lifetimes needed :'(
+ let mut title: String;
+ {
+ let book_title = ctx.data.get("book_title").and_then(serde_json::Value::as_str).unwrap_or("");
+ title = ch.name.clone() + " - " + book_title;
+ }
+
ctx.data.insert("path".to_owned(), json!(path));
ctx.data.insert("content".to_owned(), json!(content));
ctx.data.insert("chapter_title".to_owned(), json!(ch.name));
+ ctx.data.insert("title".to_owned(), json!(title));
ctx.data.insert(
"path_to_root".to_owned(),
json!(utils::fs::path_to_root(&ch.path)),
@@ -209,7 +217,7 @@ impl HtmlHandlebars {
fn configure_print_version(&self, data: &mut serde_json::Map, print_content: &str) {
// Make sure that the Print chapter does not display the title from
// the last rendered chapter by removing it from its context
- data.remove("chapter_title");
+ data.remove("title");
data.insert("path".to_owned(), json!("print.md"));
data.insert("content".to_owned(), json!(print_content));
data.insert("path_to_root".to_owned(), json!(utils::fs::path_to_root(Path::new("print.md"))));
@@ -279,6 +287,7 @@ impl Renderer for HtmlHandlebars {
// Print version
self.configure_print_version(&mut data, &print_content);
+ data.insert("title".to_owned(), json!(book.get_title()));
// Render the handlebars template with the data
debug!("[*]: Render template");
@@ -311,7 +320,7 @@ fn make_data(book: &MDBook) -> Result
let mut data = serde_json::Map::new();
data.insert("language".to_owned(), json!("en"));
- data.insert("title".to_owned(), json!(book.get_title()));
+ data.insert("book_title".to_owned(), json!(book.get_title()));
data.insert("description".to_owned(), json!(book.get_description()));
data.insert("favicon".to_owned(), json!("favicon.png"));
if let Some(livereload) = book.get_livereload() {
diff --git a/src/theme/index.hbs b/src/theme/index.hbs
index 2d30bbf0..9f735e6c 100644
--- a/src/theme/index.hbs
+++ b/src/theme/index.hbs
@@ -2,7 +2,7 @@
- {{ chapter_title }} {{#if chapter_title }}-{{/if}} {{ title }}
+ {{ title }}
@@ -85,7 +85,7 @@
-
+