{"record":{"id":"bc0f1885663c25cc","repo":"gohugoio/hugo","slug":"indexing-currently-not-supported-for-index-q-and","errorCode":null,"errorMessage":"indexing currently not supported for index %q and type %T","messagePattern":"indexing currently not supported for index %q and type %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"related/inverted_index.go","lineNumber":450,"sourceCode":"\t\tkeywords = append(keywords, cfg.stringToKeyword(vv))\n\tcase []string:\n\t\tvvv := make([]Keyword, len(vv))\n\t\tfor i := range vvv {\n\t\t\tvvv[i] = cfg.stringToKeyword(vv[i])\n\t\t}\n\t\tkeywords = append(keywords, vvv...)\n\tcase []any:\n\t\treturn cfg.ToKeywords(cast.ToStringSlice(vv))\n\tcase time.Time:\n\t\tlayout := \"2006\"\n\t\tif cfg.Pattern != \"\" {\n\t\t\tlayout = cfg.Pattern\n\t\t}\n\t\tkeywords = append(keywords, StringKeyword(vv.Format(layout)))\n\tcase nil:\n\t\treturn keywords, nil\n\tdefault:\n\t\treturn keywords, fmt.Errorf(\"indexing currently not supported for index %q and type %T\", cfg.Name, vv)\n\t}\n\n\treturn keywords, nil\n}\n\nfunc (idx *InvertedIndex) search(ctx context.Context, query ...queryElement) ([]Document, error) {\n\treturn idx.searchDate(ctx, nil, zeroDate, query...)\n}\n\nfunc (idx *InvertedIndex) searchDate(ctx context.Context, self Document, upperDate time.Time, query ...queryElement) ([]Document, error) {\n\tmatchm := make(map[Document]*rank, 200)\n\tdefer func() {\n\t\tfor _, r := range matchm {\n\t\t\tputRank(r)\n\t\t}\n\t}()\n\n\tapplyDateFilter := !idx.cfg.IncludeNewer && !upperDate.IsZero()","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/related/inverted_index.go#L432-L468","documentation":"Returned by IndexConfig.ToKeywords when the value passed for an index is of a Go type that has no keyword conversion rule. Only string, []string, []any, time.Time, and nil are handled; any other concrete type hits the default branch and fails with the offending index name and the value's %T type.","triggerScenarios":"Calling cfg.ToKeywords(v) with v being e.g. an int, float64, bool, or a custom struct -- i.e. an index field whose page value is a non-string/non-time type. Happens when a Param or front-matter field used as a related index holds a number or boolean.","commonSituations":"A front-matter field (e.g. weight: 10 as an int) is wired as a related index; a date field parsed as something other than time.Time; a custom Document whose RelatedKeywords returns a value ToKeywords cannot convert.","solutions":["Ensure indexed field values are strings, []string, or time.Time before indexing.","Convert numeric/boolean front-matter values to strings at the source, or use a custom Document.RelatedKeywords that returns properly typed Keywords.","Pick index field names that map to string-valued params only."],"exampleFix":"// before: numeric front-matter field used as index\n// front matter: weight: 10\n// related index \"weight\" calls ToKeywords(10) -> error\n\n// after: store as string or use a date/keyword field\n// front matter: tags: [\"heavy\", \"light\"]\n// [[related.indices]] name=\"tags\" weight=100","handlingStrategy":"type-guard","validationCode":"// Ensure only convertible types reach an index.\nfunc isIndexable(v any) bool {\n    switch v.(type) {\n    case string, []string, []any, time.Time, nil:\n        return true\n    }\n    return false\n}","typeGuard":"func isIndexableValue(v any) bool {\n    switch v.(type) {\n    case string, []string, []any, time.Time:\n        return true\n    case nil:\n        return true\n    default:\n        return false\n    }\n}","tryCatchPattern":"kws, err := cfg.ToKeywords(v)\nif err != nil {\n    if strings.Contains(err.Error(), \"not supported\") { /* coerce v to string and retry */ }\n}","preventionTips":["Store indexed front-matter values as strings or dates, not numbers/bools.","Implement a custom Document.RelatedKeywords to control types precisely.","Validate Param field types before wiring them as related indices."],"tags":["related","indexing","type-mismatch","keywords"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}