Add robots.txt
This commit is contained in:
parent
eb6fa3c314
commit
b0cc1ac042
10
src/site.rs
10
src/site.rs
|
@ -21,6 +21,7 @@ lazy_static! {
|
||||||
tera.add_raw_templates(vec![
|
tera.add_raw_templates(vec![
|
||||||
("rss.xml", include_str!("templates/rss.xml")),
|
("rss.xml", include_str!("templates/rss.xml")),
|
||||||
("sitemap.xml", include_str!("templates/sitemap.xml")),
|
("sitemap.xml", include_str!("templates/sitemap.xml")),
|
||||||
|
("robots.txt", include_str!("templates/robots.txt")),
|
||||||
]).unwrap();
|
]).unwrap();
|
||||||
tera
|
tera
|
||||||
};
|
};
|
||||||
|
@ -296,10 +297,19 @@ impl Site {
|
||||||
self.render_rss_feed()?;
|
self.render_rss_feed()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.render_robots()?;
|
||||||
|
|
||||||
self.render_sections()?;
|
self.render_sections()?;
|
||||||
self.copy_static_directory()
|
self.copy_static_directory()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_robots(&self) -> Result<()> {
|
||||||
|
create_file(
|
||||||
|
self.output_path.join("robots.txt"),
|
||||||
|
&self.templates.render("robots.txt", &Context::new())?
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Render the /{categories, list} pages and each individual category/tag page
|
/// Render the /{categories, list} pages and each individual category/tag page
|
||||||
/// They are the same thing fundamentally, a list of pages with something in common
|
/// They are the same thing fundamentally, a list of pages with something in common
|
||||||
fn render_categories_and_tags(&self, kind: RenderList) -> Result<()> {
|
fn render_categories_and_tags(&self, kind: RenderList) -> Result<()> {
|
||||||
|
|
1
src/templates/robots.txt
Normal file
1
src/templates/robots.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
User-agent: *
|
|
@ -99,6 +99,7 @@ fn test_can_build_site_without_live_reload() {
|
||||||
|
|
||||||
assert!(file_exists!(public, "index.html"));
|
assert!(file_exists!(public, "index.html"));
|
||||||
assert!(file_exists!(public, "sitemap.xml"));
|
assert!(file_exists!(public, "sitemap.xml"));
|
||||||
|
assert!(file_exists!(public, "robots.txt"));
|
||||||
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
||||||
|
|
||||||
assert!(file_exists!(public, "posts/python/index.html"));
|
assert!(file_exists!(public, "posts/python/index.html"));
|
||||||
|
@ -140,6 +141,7 @@ fn test_can_build_site_with_live_reload() {
|
||||||
|
|
||||||
assert!(file_exists!(public, "index.html"));
|
assert!(file_exists!(public, "index.html"));
|
||||||
assert!(file_exists!(public, "sitemap.xml"));
|
assert!(file_exists!(public, "sitemap.xml"));
|
||||||
|
assert!(file_exists!(public, "robots.txt"));
|
||||||
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
||||||
|
|
||||||
assert!(file_exists!(public, "posts/python/index.html"));
|
assert!(file_exists!(public, "posts/python/index.html"));
|
||||||
|
@ -186,6 +188,7 @@ fn test_can_build_site_with_categories() {
|
||||||
|
|
||||||
assert!(file_exists!(public, "index.html"));
|
assert!(file_exists!(public, "index.html"));
|
||||||
assert!(file_exists!(public, "sitemap.xml"));
|
assert!(file_exists!(public, "sitemap.xml"));
|
||||||
|
assert!(file_exists!(public, "robots.txt"));
|
||||||
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
||||||
|
|
||||||
assert!(file_exists!(public, "posts/python/index.html"));
|
assert!(file_exists!(public, "posts/python/index.html"));
|
||||||
|
@ -237,6 +240,7 @@ fn test_can_build_site_with_tags() {
|
||||||
|
|
||||||
assert!(file_exists!(public, "index.html"));
|
assert!(file_exists!(public, "index.html"));
|
||||||
assert!(file_exists!(public, "sitemap.xml"));
|
assert!(file_exists!(public, "sitemap.xml"));
|
||||||
|
assert!(file_exists!(public, "robots.txt"));
|
||||||
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
||||||
|
|
||||||
assert!(file_exists!(public, "posts/python/index.html"));
|
assert!(file_exists!(public, "posts/python/index.html"));
|
||||||
|
|
Loading…
Reference in a new issue