Hi, I want to list some pages on my front page and change it regularly. I think it would be easier if I can just make a list at the config.toml file and change it there to pick the right page whenever I needs to.
At my config.toml file, I add a [params.course] variables and list pages I want to show on front:
[params.course]
front = ["105","110","205"]
And in the front page template, I have:
{{ range (.GetPage "/courses").Pages "in" site.Params.course.front }}
{{ end }}
And I got error : at <"/courses">: wrong number of args for Pages: want 0 got 2"
Can anyone tell me how to get this right? Or any other better way to get this done? I know the Page.Params can do it but I don’t want to change the individule page frontmatter everytime. Thank you in advance!
{{ $courses := (.Site.GetPage "/courses").Pages }}
{{ range $courses }}
{{ $shouldShow := in $.Site.Params.course.front .File.BaseFileName }}
{{ if $shouldShow }}
<!-- Render your pages here ... -->
{{ end }}
{{ end }}
Just one more follow up question, if I want to use $.Site.Params.course.front to match section/folder instead of markdown file, how would I do it? right now, I am using .Title instead of File.BaseFileName like this:
{{ $shouldShow := in $.Site.Params.course.front .Title }}
the .Title only show the title from _index.md front matter filed but not the actual sub section/folder name, like 105. then I had to set both languages of the title for the $.Site.Params.course.front I am wondering is there are something like .Title but for the actual section/folder name? would be great to fix my problem.