{"record":{"id":"6e29eea08ce9305d","repo":"DioxusLabs/dioxus","slug":"document-should-have-a-head","errorCode":null,"errorMessage":"document should have a head","messagePattern":"document should have a head","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/web/src/document.rs","lineNumber":174,"sourceCode":"        });\n    }\n\n    /// Create a new link tag in the head\n    fn create_link(&self, props: LinkProps) {\n        queue_effect(move || {\n            _ = append_element_to_head(\"link\", &props.attributes(), None);\n        });\n    }\n}\n\nfn append_element_to_head(\n    local_name: &str,\n    attributes: &Vec<(&'static str, String)>,\n    text_content: Option<&str>,\n) -> Result<(), JsValue> {\n    let window = web_sys::window().expect(\"no global `window` exists\");\n    let document = window.document().expect(\"should have a document on window\");\n    let head = document.head().expect(\"document should have a head\");\n\n    let element = document.create_element(local_name)?;\n    for (name, value) in attributes {\n        element.set_attribute(name, value)?;\n    }\n    if text_content.is_some() {\n        element.set_text_content(text_content);\n    }\n    head.append_child(&element)?;\n\n    Ok(())\n}\n\n/// Required to avoid blocking the Rust WASM thread.\nconst PROMISE_WRAPPER: &str = r#\"\n    return (async function(){\n        {JS_CODE}\n","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/web/src/document.rs#L156-L192","documentation":"`append_element_to_head` gets the document's head element and `expect`s it to exist. This panic fires when the document has no `<head>` (malformed or minimal documents in unusual web contexts) while injecting meta/script/style/link elements.","triggerScenarios":"Thrown at packages/web/src/document.rs:174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the document has a <head> element (a normal HTML document does); provide a valid index.html when rendering on web."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}