{"record":{"id":"aef6e3091235f56e","repo":"leptos-rs/leptos","slug":"you-are-using-leptos-meta-without-a-head-tag","errorCode":null,"errorMessage":"you are using leptos_meta without a </head> tag","messagePattern":"you are using leptos_meta without a </head> tag","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"meta/src/lib.rs","lineNumber":251,"sourceCode":"            .map(|n| \"<title>\".len() + n.len() + \"</title>\".len())\n            .unwrap_or(0);\n\n        // collect all registered meta tags\n        let meta_buf = self.elements.try_iter().collect::<String>();\n\n        // get HTML strings for `<html>` and `<body>`\n        let html_attrs = self.html.try_iter().collect::<String>();\n        let body_attrs = self.body.try_iter().collect::<String>();\n\n        let mut modified_chunk = if title_len == 0 && meta_buf.is_empty() {\n            first_chunk\n        } else {\n            let mut buf = String::with_capacity(\n                first_chunk.len() + title_len + meta_buf.len(),\n            );\n            let head_loc = first_chunk\n                .find(\"</head>\")\n                .expect(\"you are using leptos_meta without a </head> tag\");\n            let marker_loc = first_chunk\n                .find(\"<!--HEAD-->\")\n                .map(|pos| pos + \"<!--HEAD-->\".len())\n                .unwrap_or_else(|| {\n                    first_chunk.find(\"</head>\").unwrap_or(head_loc)\n                });\n            let (before_marker, after_marker) =\n                first_chunk.split_at_mut(marker_loc);\n            buf.push_str(before_marker);\n            buf.push_str(&meta_buf);\n            if let Some(title) = title {\n                buf.push_str(\"<title>\");\n                buf.push_str(&title);\n                buf.push_str(\"</title>\");\n            }\n            buf.push_str(after_marker);\n            buf\n        };","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/meta/src/lib.rs#L233-L269","documentation":"During server-side rendering, leptos_meta rewrites the first HTML chunk to insert title/meta tags. It expects the string \"</head>\" to be present in that chunk and panics with this message if it cannot be found. The library throws it because the streaming-injection strategy requires a literal closing head tag to anchor insertion.","triggerScenarios":"Calling from_app/inject_meta_context with an HTML template whose first chunk lacks the literal \"</head>\" — e.g. minified/transformed templates, templates using uppercase <HEAD>, or head content streamed in a later chunk.","commonSituations":"Custom React-like templates or framework wrappers that emit <head/> self-closed or omit the closing tag; build tools (minifiers, HTML rewriters) reformatting \"</head>\"; injecting leptos_meta into apps whose shell doesn't use a standard head.","solutions":["Ensure the app template's first streamed chunk contains a literal \"</head>\" (lowercase, with the closing slash).","Optionally include the \"<!--HEAD-->\" marker comment in <head> so leptos_meta can anchor injection there.","Disable HTML minification/rewriting of the head in your SSR pipeline, or configure it to preserve \"</head>\" verbatim.","Verify the head markup isn't split across stream chunks before leptos_meta processes it."],"exampleFix":"<!-- before: transformed shell -->\n<head><meta charset=\"utf-8\"/>\n\n<!-- after -->\n<head><meta charset=\"utf-8\"><!--HEAD--></head>","handlingStrategy":"validation","validationCode":"if !first_chunk.contains(\"</head>\") {\n    return Err(anyhow!(\"SSR shell must contain a literal </head> for leptos_meta\"));\n}","typeGuard":"fn shell_has_head_close(html: &str) -> bool {\n    html.contains(\"</head>\")\n}","tryCatchPattern":null,"preventionTips":["Keep a lowercase literal \"</head>\" in the first streamed chunk.","Add the <!--HEAD--> marker comment inside <head>.","Disable minifiers/rewriters that alter the head markup in SSR output."],"tags":["leptos","ssr","meta","html-template"],"backgroundTag":"missing-head-tag-in-ssr-shell","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}