If you've ever tried to save a custom Blogger template and suddenly got hit with this scary-looking error message:
"org.xml.sax.SAXParseException; lineNumber: 134; columnNumber: 182; The reference to entity "l" must end with the ';' delimiter."
You're not alone. This is one of the most common errors Blogger developers face when working with custom templates — and today, I'm going to show you exactly how I fixed it, step by step.
Whether you're a blogger upgrading your theme, adding Google Tag Manager, or editing someone else's template, this guide will save you hours of frustration.
What Causes This Error?
Blogger templates are written in XML (eXtensible Markup Language), which is much stricter than HTML. In XML, certain characters have special meanings — and if you use them incorrectly, the entire template refuses to save.
The ampersand symbol (&) is the main culprit. In XML, & is a reserved character used to start "entities" like:
&→ renders as&<→ renders as<>→ renders as>
So when Blogger sees a raw & in your code — like the one inside Google Tag Manager's tracking URL (?&l=dataLayer) — it expects it to be part of a proper entity that ends with a semicolon (;).
When that semicolon is missing, you get:
"The reference to entity 'l' must end with the ';' delimiter."
In my case, the error was on line 134 — right inside the Google Tag Manager (GTM) script.
The Broken Code (What I Had)
Here's the GTM snippet that was causing the problem:
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
See that part: '&l='+l? That single & is what broke the entire template.
Solution 1: Escape the Ampersand (Quickest Fix)
The simplest fix is to replace the raw & with its XML-safe equivalent &:
Change this:
dl = l != 'dataLayer' ? '&l=' + l : '';
To this:
dl = l != 'dataLayer' ? '&l=' + l : '';
In Blogger's HTML editor, this reads as one character change, but the parser now sees a valid entity and the error disappears.
Solution 2: Wrap JavaScript in CDATA (Best Practice)
Instead of escaping every special character, the professional way is to wrap the entire script inside a CDATA block. This tells Blogger's XML parser to treat everything inside as raw text — no escaping needed.
Correct format:
<script>//<![CDATA[
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');
//]]></script>
Notice the //<![CDATA[ at the start and //]]> at the end. That's the magic trick.
Pro tip: From now on, always wrap every <script> tag in your Blogger template with CDATA. It prevents 90% of XML errors before they happen.
Other XML Errors I Found & Fixed
While debugging, I discovered 5 more hidden issues that would have caused problems later. Fix them all in one go:
1. Self-Closing Script Tags
Wrong:
<script src='file.js' type='text/javascript'/>
Right:
<script src='file.js' type='text/javascript'></script>
Blogger doesn't reliably handle self-closing script tags. Always use the full closing tag.
2. Self-Closing Iframes
Wrong:
<iframe src='' width='100%'/>
Right:
<iframe src='' width='100%'></iframe>
3. Ampersands in URLs
Any URL inside your template with & must use & instead:
Wrong: https://example.com?q=test&page=2
Right: https://example.com?q=test&page=2
Quick Search & Replace Table (Save This)
Use Ctrl+F in Blogger's HTML editor to find and fix each one:
| Search For | Replace With |
|---|---|
'&l=' | '&l=' |
.js' type='text/javascript'/> | .js' type='text/javascript'></script> |
width='0'/> | width='0'></iframe> |
src='' width='100%'/> | src='' width='100%'></iframe> |
How to Verify Your Fix Worked
After making changes, follow these steps:
- Save the template in Theme → Edit HTML. If it saves without error, you're 90% done.
- Visit your blog on both desktop and mobile — make sure everything still works.
- Run your URL through the W3C Validator.
- Test structured data with Google Rich Results Test.
- Check Google Search Console for crawl errors after 48 hours.
How to Prevent This Error in Future
Follow these golden rules whenever editing Blogger templates:
- ✅ Always wrap scripts in CDATA —
//<![CDATA[ ... //]]> - ✅ Never use raw
&— always write& - ✅ Close all tags properly — no self-closing
<script/>or<iframe/> - ✅ Backup before editing — Theme → Backup → Download
- ✅ Edit in a real code editor first (VS Code, Notepad++) to catch errors
- ✅ Test on a staging blog before applying to your main blog
Bonus: The Fastest Way to Debug XML Errors
When Blogger throws an XML error, it gives you a line number and column number. Here's the trick:
- Open the Blogger HTML editor
- Press Ctrl+G (or use browser search)
- Count to the line shown in the error
- Look for the column number from the left
- The problem character will be right there
In my case: Line 134, Column 182 → the exact & in '&l='.
Final Thoughts
The "reference to entity must end with the ';' delimiter" error looks terrifying, but it's actually one of the easiest Blogger errors to fix once you understand why it happens. It's not a bug in your code — it's just XML being strict about special characters.
After applying all the fixes above, my template now:
- ✅ Saves without any errors
- ✅ Loads 40% faster (removed duplicate jQuery + obfuscated scripts)
- ✅ Works perfectly on mobile (fixed clickable widget links)
- ✅ Passes W3C validation
- ✅ Scores 90+ on Google PageSpeed Insights
If this guide helped you fix your Blogger XML error, share it with other bloggers who might be struggling with the same issue. And if you have a different XML error, drop it in the comments — I'll help you debug it.
Happy blogging! 🚀
Found this helpful? Subscribe to Dedontech for more Blogger tips, tech tutorials, and web development guides for Nigerians and Africans.
0 Comments: