Can't add archive page

Here’s my github repository:

I am using this zwbetz’s make-a-hugo-blog-from-scratch to teach myself about hugo.

I have configured the config file and added categories.

I am working on archives page. I am stuck here

Based on research, I have added archive.md under content/archive.md

Also, I have added layout/archive/archive.html.

But the Archive page is still empty.

Where did I go wrong? Thankyou in advance.

You mix up taxonomies and ranging over grouped pages.

you defined a taxonomy archives but

  • none of your pages is assigned to that category.
  • so the categories page at `/categories/archives is empty (where your menu is pointing too)
  • this is rendered by your term.html

your content/archive.md

  • is rendered to /categories/archive/index.html (you don’t have a menu for that)
  • this is rendered by archive/single.html
  • this will show nothing, because your layout ranging is incorrect
       {{ $type := .Params.archivetype }}                         This is undefined
       {{ range (.Site.RegularPages.GroupByDate "2006") }}        This gets your page groups
          {{ $posts := (where .Pages "Type" $type) }}             This gets nothing because $type is unset
          ...   # did not check stuff below
    

the guide is rather old so I used hugo 0.128.1

@Datwins that guide Make a Hugo Blog From Scratch | Zachary Betz is indeed old and doesn’t utilise the current features of Hugo.

I would suggest you run either of these two commands to see and study the files generated by Hugo.

  1. This generates a theme inside the themes folder with content and layouts
hugo new site quickstart
cd quickstart
hugo new theme quickstart-theme
echo "theme = 'quickstart-theme'" >> hugo.toml
hugo server
  1. This generates the layouts and content at the site root.
hugo new theme quickstart --themesDir .
cd quickstart
hugo server

Thank you for your time.

Does it matter if it’s an older version of hugo?

My workflow is simple.

  1. Fork repository.
  2. Make changes to content.
  3. Deploy to netlify. Bam, it does the job.
    I can explain this process to other noobies especially to my grandma who’s doing it to save her recipe.

Thank you for your time.
Can you suggest a solution? I will delete the layout/archive folder and the taxonomies.
I will keep content/archive.md.

Does Hugo provide a code template where I can copy?

All I did was copy and paste the lines that you see.

in principle you can stay on older versions. if you dont need the new features or security patches but…one time you will want to.

if you just start, then it might be better to start with the latest version.

with 146+ the template organization got a major rewrite. so some old stuff does not work. and many stuff out there is besed on older versions.

in general copy paste without understanding what and why will somedy break… you will have to spend some time for reading and learning.

if you want an archives page showing a list of pages grouped by year you can:

  • remove the archives taxonomy
  • rename archive.md to archives.md
  • fix the looping

Thank you for your time and advice. I just want something plain and vanilla. I only need blog, tag, categories, and archives.

I remove the archives taxonomy. Rename ** archive.md** to ** archives.md**

Now, it shows Jan 1, 0001

How do I fix the looping?

I read that you have to create layout/archives/single.html. Does this do the job? Please point me in the right direction.

Have look at the docs here GroupByDate. start simple using one of the examples.

no need for that. just modify you existing layout.