gohugoio/hugo · error
URLs with protocol (http*) not supported: %q. In page %q
Error message
URLs with protocol (http*) not supported: %q. In page %q
What it means
The `url` front matter field sets a site-relative permalink for the page; Hugo rejects values starting with http:// or https:// because a fully-qualified external URL cannot be a page's output path within the site. The error includes the page path or title to locate the offending file.
Source
Thrown at hugolib/page__meta.go:722
pcfg.Title = cast.ToString(v)
pcfg.Params[loki] = pcfg.Title
case "linktitle":
pcfg.LinkTitle = cast.ToString(v)
pcfg.Params[loki] = pcfg.LinkTitle
case "summary":
pcfg.Summary = cast.ToString(v)
pcfg.Params[loki] = pcfg.Summary
case "description":
pcfg.Description = cast.ToString(v)
pcfg.Params[loki] = pcfg.Description
case "slug":
// Don't start or end with a -
pcfg.Slug = strings.Trim(cast.ToString(v), "-")
pcfg.Params[loki] = pm.Slug()
case "url":
url := cast.ToString(v)
if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") {
return fmt.Errorf("URLs with protocol (http*) not supported: %q. In page %q", url, ps.pathOrTitle())
}
pcfg.URL = url
pcfg.Params[loki] = url
case "type":
pcfg.Type = cast.ToString(v)
pcfg.Params[loki] = pcfg.Type
case "keywords":
pcfg.Keywords = cast.ToStringSlice(v)
pcfg.Params[loki] = pcfg.Keywords
case "headless":
// Legacy setting for leaf bundles.
// This is since Hugo 0.63 handled in a more general way for all
// pages.
isHeadless := cast.ToBool(v)
pcfg.Params[loki] = isHeadless
if isHeadless {
pm.pageConfig.Build.List = pagemeta.Never
pm.pageConfig.Build.Render = pagemeta.NeverView on GitHub ↗ (pinned to 8a468df065)
Solutions
- Use a site-relative path: `url: /my/page/` — Hugo prefixes baseURL at render time.
- For external links in menus, define them in site config under menus with an external URL rather than as a content page.
- For redirects to external sites, use an alias-free approach such as a layout with meta refresh or server-level redirects.
Example fix
# before --- url: https://example.com/blog/my-post/ --- # after --- url: /blog/my-post/ ---
Defensive patterns
Strategy: validation
Validate before calling
// Validate url front matter before build
if u, ok := fm["url"].(string); ok {
if strings.HasPrefix(u, "http://") || strings.HasPrefix(u, "https://") {
return fmt.Errorf("page url must be relative, got %q", u)
}
} Type guard
func isRelativeURL(u string) bool {
return !strings.HasPrefix(strings.ToLower(u), "http")
} Try / catch
if err := site.Build(); err != nil {
if strings.Contains(err.Error(), "URLs with protocol") {
// strip scheme+host; set only the path in the page's url field
}
return err
} Prevention
- Use site-relative paths in a page's `url` front matter (`/blog/my-post/`), never absolute URLs
- Set the site host via `baseURL` in the site config, not per-page
- Grep content front matter for `url: http` in CI to catch this before builds fail
When it happens
Trigger: A content file's front matter contains `url: https://example.com/...`. Hit during page metadata processing (setMetaPost) for any build/serve.
Common situations: Users trying to make a menu entry or redirect to an external site via page `url`, migrating from other SSGs where url could be absolute, or accidentally pasting a full production URL including the domain instead of the path.
Related errors
- error processing file %q
- failed to parse file %q: %s
- failed to convert metadata for file %q: %s
- errWrongArgStructure
- %s isn't a field of struct type %s
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/4b7e4842e585a587.json.
Report an issue: GitHub ↗.