Use Template Engine

Salvo doesn't have a templating engine built in; after all, the style of templating you like to use varies from person to person.

A template engine is essentially: data + template = string.

So, any template engine can be supported as long as it can render the final string.

For example, we can use askama like so:


Hello, {{ name }}!


use askama::Template;
use salvo::prelude::*;

#[template(path = "hello.html")]
struct HelloTemplate<'a> {
    name: &'a str,

async fn hello_world(req: &mut Request, res: &mut Response) {
    let hello = HelloTemplate {
        name: req.param::<&str>("name").unwrap_or("World"),

async fn main() {

    tracing::info!("Listening on");
    let router = Router::with_path("<name>").get(hello_world);
    let acceptor = TcpListener::new("").bind().await; Server::new(acceptor).serve(router).await;