Hi everyone,
Since we have content adapters, I’m trying to migrate all contents into json data. But I’m still confused about the tags and keywords system under this new feature. How should I configure relarted contents? This is how I use a content adapter to create pages:
<h4>See Also:</h4>
{{ $opt := dict
"indices" "tags"
"document" .
"namedSlices" (slice (keyVals "tags" "Docker"))
}}
{{ $related := .Site.RegularPages.Related $opt | first 3 }}
{{ with $related }}
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
It seems Hugo cannot doesn’t recognize the param ‘tags’, because I got this error: executing "main" at <.Site.RegularPages.Related>: error calling Related: index "tags" not found
Is there any clue how this happened?
{
"posts":[
{
"title": "Introduction to Machine Learning",
"author": "Bob",
"tags": ["Machine Learning", "AI", "Data Science"],
"date": "2023-11-20",
"category": "AI",
"content": "Machine learning is one of the core technologies of artificial intelligence, widely used in image recognition, natural language processing, and other fields. This article will introduce the basic concepts and common algorithms of machine learning.\n\n## Main Content\n- **Supervised Learning**: Such as linear regression and classification algorithms.\n- **Unsupervised Learning**: Such as clustering and dimensionality reduction.\n- **Model Evaluation**: Using metrics like accuracy and recall.\n\n```python\n# Example code\nfrom sklearn.linear_model import LinearRegression\nmodel = LinearRegression()\nmodel.fit(X_train, y_train)\n```"
}
]
}