usememos/memos · info
not a HTML page
Error message
not a HTML page
What it means
The HTML metadata getter fetched the URL successfully but the response Content-Type was not exactly text/html, so there is no HTML to extract a title/description from. The check is on the parsed mediatype, so parameters like charset are stripped first.
Source
Thrown at internal/httpgetter/html_meta.go:152
}
func GetHTMLMeta(urlStr string) (*HTMLMeta, error) {
if err := validateURL(urlStr); err != nil {
return nil, err
}
response, err := httpClient.Get(urlStr)
if err != nil {
return nil, err
}
defer response.Body.Close()
mediatype, err := getMediatype(response)
if err != nil {
return nil, err
}
if mediatype != "text/html" {
return nil, errors.New("not a HTML page")
}
htmlMeta := extractHTMLMeta(io.LimitReader(response.Body, maxHTMLMetaBytes))
enrichSiteMeta(response.Request.URL, htmlMeta)
return htmlMeta, nil
}
func extractHTMLMeta(resp io.Reader) *HTMLMeta {
tokenizer := html.NewTokenizer(resp)
htmlMeta := new(HTMLMeta)
for {
tokenType := tokenizer.Next()
if tokenType == html.ErrorToken {
break
} else if tokenType == html.StartTagToken || tokenType == html.SelfClosingTagToken {
token := tokenizer.Token()
if token.DataAtom == atom.Body {View on GitHub (pinned to 14d757ce1f)
Solutions
- Link to the HTML page that embeds/links the resource, not the resource itself
- If you own the server, ensure HTML pages are served with `Content-Type: text/html; charset=utf-8`
- Handle this error gracefully in UI: skip preview generation instead of showing a failure
Example fix
// before
GetHTMLMeta("https://example.com/report.pdf")
// after
GetHTMLMeta("https://example.com/reports/report") // HTML landing page Defensive patterns
Strategy: try-catch
Validate before calling
// Optional pre-check via HEAD (best effort; server may lie)
func looksLikeHTML(u string) bool {
resp, err := http.Head(u)
if err != nil { return true } // let the real fetcher decide
ct := resp.Header.Get("Content-Type")
return strings.HasPrefix(ct, "text/html")
} Try / catch
// Not-a-page is expected for non-HTML links: skip the preview silently
if _, err := getter.GetHTMLMeta(u); err != nil {
if strings.Contains(err.Error(), "not a HTML page") { return nil }
return err
} Prevention
- Treat metadata extraction as best-effort; never fail note creation for it
- Prefer linking to HTML landing pages over raw files
- Check Content-Type handling if you control the target server
When it happens
Trigger: Fetching a PDF, image, JSON API endpoint, plain-text file, or a download link (Content-Disposition attachments often serve application/octet-stream) through the link-preview path.
Common situations: Pasting a direct link to a PDF, raw GitHub file, image, or API endpoint into a memo; servers misconfigured to serve HTML pages as text/plain; endpoints that content-negotiate to JSON for non-browser clients.
Related errors
- wrong image mediatype
- too many redirects
- internal IP addresses are not allowed
- hostname resolved to no addresses
- invalid URL format
AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15).
Data as JSON: /api/errors/1c3f20edc9e9d5f7.
Report an issue: GitHub.