diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 60d9afc..1d3c27e 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -536,6 +536,26 @@ impl Site { /// Deletes the `public` directory and builds the site pub fn build(&self) -> Result<()> { self.clean()?; + + // Generate/move all assets before rendering any content + if let Some(ref theme) = self.config.theme { + let theme_path = self.base_path.join("themes").join(theme); + if theme_path.join("sass").exists() { + self.compile_sass(&theme_path)?; + } + } + + if self.config.compile_sass { + self.compile_sass(&self.base_path)?; + } + + self.process_images()?; + self.copy_static_directories()?; + + if self.config.build_search_index { + self.build_search_index()?; + } + // Render aliases first to allow overwriting self.render_aliases()?; self.render_sections()?; @@ -570,24 +590,6 @@ impl Site { self.render_robots()?; self.render_taxonomies()?; - if let Some(ref theme) = self.config.theme { - let theme_path = self.base_path.join("themes").join(theme); - if theme_path.join("sass").exists() { - self.compile_sass(&theme_path)?; - } - } - - if self.config.compile_sass { - self.compile_sass(&self.base_path)?; - } - - self.process_images()?; - self.copy_static_directories()?; - - if self.config.build_search_index { - self.build_search_index()?; - } - Ok(()) }