Favicon, page title
You can do reactive things also in in the
<head>
element.
use vertigo::{dom, include_static, router::Router}; #[derive(Clone, PartialEq)] enum Route { Page1, Page2, } impl std::fmt::Display for Route { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let subpage = match self { Route::Page1 => "/page1", Route::Page2 => "/page2", }; write!(f, "My Page -- {subpage}") } } impl From<String> for Route { fn from(value: String) -> Self { match value.as_str() { "/page2" => Self::Page2, _ => Self::Page1, } } } impl Route { pub fn into_title(self) -> &'static str { match self { Route::Page1 => "Page 1", Route::Page2 => "Page 2", } } } let routing = Router::<Route>::new_history_router(); let page_title = routing.route.map(Route::into_title); dom! { <html> <head> <title>{page_title}</title> <meta charset="utf-8" /> <meta name="Keywords" content="Vertigo, Rust, Wasm, Reactive, Examples" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="icon" href={include_static!("favicon.ico")} /> <style>" html { box-sizing: border-box; font-size: 16px; } *, *:before, *:after { box-sizing: inherit; } "</style> </head> <body> "Hello world" </body> </html> }