Hello everyone! I am in the process of migrating my blog from WordPress to Hugo, and I’ve encountered an issue.
I am using the hugo-theme-stack theme, and I want to exclude articles from two categories from appearing on the homepage. I have modified the layouts/index.html, but it doesn’t seem to be working. I also tried modifying the layouts/_default/list.html , but that didn’t work either.I have searched for a long time on the forum, but I haven’t found a suitable method.
Thank you for your assistance. Since I am not proficient in Go language, following your guidance, I used 3 method, but it still doesn’t work. The homepage continues to display all the articles.
I suggest you follow my earlier guidance. It works great. Try it:
git clone --single-branch -b hugo-forum-topic-50046 https://github.com/jmooring/hugo-testing hugo-forum-topic-50046
cd hugo-forum-topic-50046
hugo server
Files of interest:
layouts/_default/home.html (lines 13-21)
Also, when posting code, configuration, or data on this forum, please wrap the text within tripple backticks or use the </> button in the menu.
I am sorry, in fact, I had copied your code earlier, but it did not work. After reviewing your test code, I even copied the entire home.html to my index.html, but it still display all the articles.
I tried creating a /content/page/test/index.md, and added a test.html under layouts/page, and copied your code into it, it works well.
I am wondering if this issue is caused by the special settings of the theme, but I haven’t received a response yet after submitting an issue on GitHub.
Just now, I found the source of the problem. The hugo-theme-stack sets another file to control the display of articles on the homepage, located at layouts/partials/data/title.html. By modifying this file, I have achieved my goal.
Thank you once again for your help; it was my carelessness when searching for the function earlier that caused me to overlook it. When I re-searching for {{ $pag := .Paginate ($filtered) }} that I discovered this code also existed in another file.