# LWC1075
Represents an error for a template that contains more than one root-level node.
Severity: Error
# Message
Multiple roots found
Example diagnostic message:
LWC1075: Multiple roots found
# Problem
LWC1075 occurs when a template file contains more than one root-level node. LWC templates must have exactly one root <template> element with no other content outside of it. Any additional elements, text, or non-whitespace content alongside the root <template> tag triggers this error.
# Examples
Here are several scenarios that can trigger this error.
# 1. Text Outside the Template Tag
Placing text or code outside the <template> tag — whether before the opening tag or after the closing tag — creates a second root node. Even stray text such as leftover code or accidental content triggers this error.
# Examples with Errors
Here are several examples that return error code LWC1075.
Text after the closing template tag:
<template>
<root></root>
</template>
Obj.get()
Error Message:
LWC1075: Multiple roots found
Text before the opening template tag:
Some text before
<template>
<div>Content</div>
</template>
Error Message:
LWC1075: Multiple roots found
# Error Resolution Examples
Here's how you can fix error code LWC1075.
Remove or move all content inside the <template> tag:
<template>
<root></root>
</template>
# 2. Multiple Template Tags
A template file must contain exactly one <template> element at the root level. Having two <template> tags creates two root elements, which isn’t allowed.
# Examples with Errors
Here's an example that returns error code LWC1075.
Two template elements in the same file:
<template>
<div>First</div>
</template>
<template>
<div>Second</div>
</template>
Error Message:
LWC1075: Multiple roots found
# Error Resolution Examples
Here's how you can fix error code LWC1075.
Merge all content into a single <template> tag:
<template>
<div>First</div>
<div>Second</div>
</template>
# 3. HTML Element After the Closing Template Tag
Placing an HTML element outside and after the <template> tag creates a second root element. All markup must be inside the single root <template>.
# Examples with Errors
Here's an example that returns error code LWC1075.
An element after the closing template tag:
<template>
<div>Main content</div>
</template>
<div>Extra content</div>
Error Message:
LWC1075: Multiple roots found
# Error Resolution Examples
Here's how you can fix error code LWC1075.
Move all elements inside the <template> tag:
<template>
<div>Main content</div>
<div>Extra content</div>
</template>
# Suggested Fix Steps
Consider these suggestions to fix LWC1075 errors.
# Step 1: Locate the Extra Root Content
Check the template file for any content outside the root <template> tag — before the opening <template> or after the closing </template>. Look for stray text, extra elements, or duplicate <template> tags.
# Step 2: Consolidate Into a Single Root
- If there are duplicate
<template>tags, merge their contents into one - If there’s stray text or elements outside the template, either move them inside or remove them
- Ensure that the file has exactly one
<template>element at the root with all component markup inside it
For specific code examples, see the preceding Error Resolution Examples section.
# Step 3: Verify the Fix
- Re-compile your template
- Make sure that LWC1075 no longer appears
- Confirm that your component renders as expected