{"id":"4b7e4842e585a587","repo":"gohugoio/hugo","slug":"urls-with-protocol-http-not-supported-q-in-p","errorCode":null,"errorMessage":"URLs with protocol (http*) not supported: %q. In page %q","messagePattern":"URLs with protocol \\(http\\*\\) not supported: %q\\. In page %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page__meta.go","lineNumber":722,"sourceCode":"\t\t\tpcfg.Title = cast.ToString(v)\n\t\t\tpcfg.Params[loki] = pcfg.Title\n\t\tcase \"linktitle\":\n\t\t\tpcfg.LinkTitle = cast.ToString(v)\n\t\t\tpcfg.Params[loki] = pcfg.LinkTitle\n\t\tcase \"summary\":\n\t\t\tpcfg.Summary = cast.ToString(v)\n\t\t\tpcfg.Params[loki] = pcfg.Summary\n\t\tcase \"description\":\n\t\t\tpcfg.Description = cast.ToString(v)\n\t\t\tpcfg.Params[loki] = pcfg.Description\n\t\tcase \"slug\":\n\t\t\t// Don't start or end with a -\n\t\t\tpcfg.Slug = strings.Trim(cast.ToString(v), \"-\")\n\t\t\tpcfg.Params[loki] = pm.Slug()\n\t\tcase \"url\":\n\t\t\turl := cast.ToString(v)\n\t\t\tif strings.HasPrefix(url, \"http://\") || strings.HasPrefix(url, \"https://\") {\n\t\t\t\treturn fmt.Errorf(\"URLs with protocol (http*) not supported: %q. In page %q\", url, ps.pathOrTitle())\n\t\t\t}\n\t\t\tpcfg.URL = url\n\t\t\tpcfg.Params[loki] = url\n\t\tcase \"type\":\n\t\t\tpcfg.Type = cast.ToString(v)\n\t\t\tpcfg.Params[loki] = pcfg.Type\n\t\tcase \"keywords\":\n\t\t\tpcfg.Keywords = cast.ToStringSlice(v)\n\t\t\tpcfg.Params[loki] = pcfg.Keywords\n\t\tcase \"headless\":\n\t\t\t// Legacy setting for leaf bundles.\n\t\t\t// This is since Hugo 0.63 handled in a more general way for all\n\t\t\t// pages.\n\t\t\tisHeadless := cast.ToBool(v)\n\t\t\tpcfg.Params[loki] = isHeadless\n\t\t\tif isHeadless {\n\t\t\t\tpm.pageConfig.Build.List = pagemeta.Never\n\t\t\t\tpm.pageConfig.Build.Render = pagemeta.Never","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/page__meta.go#L704-L740","documentation":"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.","triggerScenarios":"A content file's front matter contains `url: https://example.com/...`. Hit during page metadata processing (setMetaPost) for any build/serve.","commonSituations":"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.","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."],"exampleFix":"# before\n---\nurl: https://example.com/blog/my-post/\n---\n# after\n---\nurl: /blog/my-post/\n---","handlingStrategy":"validation","validationCode":"// Validate url front matter before build\nif u, ok := fm[\"url\"].(string); ok {\n    if strings.HasPrefix(u, \"http://\") || strings.HasPrefix(u, \"https://\") {\n        return fmt.Errorf(\"page url must be relative, got %q\", u)\n    }\n}","typeGuard":"func isRelativeURL(u string) bool {\n    return !strings.HasPrefix(strings.ToLower(u), \"http\")\n}","tryCatchPattern":"if err := site.Build(); err != nil {\n    if strings.Contains(err.Error(), \"URLs with protocol\") {\n        // strip scheme+host; set only the path in the page's url field\n    }\n    return err\n}","preventionTips":["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"],"tags":["hugo","front-matter","url","permalinks"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}