A missing charset declaration means the page does not say which character encoding its text uses. Browsers then guess, and when they guess wrong, accented letters, quotes and symbols turn into garbled characters such as café instead of café. Lighthouse reports it as Charset declaration is missing or occurs too late in the HTML. The fix is <meta charset="utf-8"> as the first tag in <head>, matched by a charset=utf-8 HTTP header.
What a charset declaration is
A computer stores text as bytes, and the encoding says how to turn those bytes back into letters. UTF-8 covers every language and is the only encoding the HTML standard recommends. You can declare it in two places.
In the HTML, as the first element in <head>:
<head>
<meta charset="utf-8">
<title>Café menu</title>
</head>
In the HTTP response header the server sends:
Content-Type: text/html; charset=utf-8
The meta tag has to appear within the first 1024 bytes of the page, because browsers only look that far before they start parsing. When both are present, the HTTP header wins, so the two must agree.
Why it matters
- Garbled text. If a browser decodes UTF-8 bytes as a legacy encoding, every non ASCII character breaks. That is called mojibake, and it makes the page look broken and untrustworthy.
- Search engines and AI read the same bytes. Crawlers decode the page before they index it or quote it. A wrong encoding can leave broken characters in your search snippet or in an AI answer.
- Slower rendering. When the declaration comes late, a browser may have to throw away what it parsed and start again with the right encoding.
- Security. Pages without a declared encoding were historically open to attacks that rely on the browser guessing an unexpected encoding. Declaring UTF-8 removes the guess.
Why it happens
- Old or hand written templates that never had the tag.
- The tag is too late in
<head>. Large inline scripts, styles or comments before it push it past the first 1024 bytes. - Custom templates and exported pages that output their own
<head>without it. - The server sends no charset, so the page relies on the meta tag alone, or sends a different one, such as
ISO-8859-1, that overrides the tag. - The file is not saved as UTF-8. Declaring UTF-8 on text saved in another encoding produces the same garbled output.
How to find a missing charset declaration
-
Check a single page. View the source and confirm
<meta charset="utf-8">is the first tag inside<head>. In Chrome DevTools, open Network, select the page and read theContent-Typeresponse header. From a terminal:bash curl -sI https://example.com/ | grep -i content-type -
Run Lighthouse. The best practices audit flags Charset declaration is missing or occurs too late in the HTML.
-
Check every page. UpCrawler flags Missing charset declaration on any page whose HTML declares no character encoding. Most flagged pages share one template, so fixing it there clears them all.
How to fix it
- Add
<meta charset="utf-8">as the very first element in<head>, before the title, scripts and styles. While you are in the base template, check that the<html>tag declares the page language too. - Send a matching header. Configure the server or CDN to send
Content-Type: text/html; charset=utf-8. In nginx that ischarset utf-8;, in ApacheAddDefaultCharset UTF-8. - Save files and store content as UTF-8, including the database connection, so the bytes match the declaration.
- Remove conflicting declarations, such as an old
http-equiv="Content-Type"meta tag with a different charset.
The App Router adds <meta charset="utf-8"> to every page automatically, together with the viewport tag, and serves HTML with a UTF-8 header. Do not add your own.
Classic themes print the tag in header.php, first inside <head>, using the encoding from WordPress settings:
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
New sites use UTF-8 by default. If the tag is missing, add it to a child theme. If it is present but text is still garbled, check DB_CHARSET in wp-config.php and the database tables, which should both be utf8mb4. Block themes get the tag from WordPress core.
The tag belongs at the top of <head> in layout/theme.liquid:
<head>
<meta charset="utf-8">
Shopify serves pages as UTF-8, and current themes include the tag. If a page is flagged, check alternate layouts in the layout folder and move the tag above any snippets rendered before it.
Let AI fix it, page by page.
Paste this prompt into AI with your project open. In UpCrawler, every affected page comes with a prompt like this, already filled in with its URL.
Add <meta charset="utf-8"> as the first element in <head> and make the server send a matching Content-Type charset.
Frequently asked questions
What charset should I use?
UTF-8. It covers every language and symbol, it is the encoding the HTML standard recommends, and it is what every modern CMS and framework uses by default.
Where should the meta charset tag go?
First inside <head>, before the title and any scripts or styles. It must appear within the first 1024 bytes of the HTML, or browsers may ignore it.
Is meta charset or the Content-Type header more important?
The header takes precedence when both are present, so it decides how the page is decoded. Set both to UTF-8: the header for browsers and crawlers, and the meta tag for saved copies and any server that drops the header.
Why do I see characters like é on my site?
The text is stored as UTF-8 but decoded as a legacy encoding such as Windows-1252. Declare UTF-8 in the header and the meta tag, and check that your database and files are UTF-8 too.
Share it with whoever runs your site’s SEO.