Permalinks not working, converting jupyter notebooks to hugo blog posts

Hi there.

I’ve been banging my head on the same issue for 3 or so days now and I figured it might make sense to ask for some help. I am by no means a Hugo expert so please bear with me if I say things that seem silly in the eye of you experts.

The problem I’m running into: my permalinks are not working (throwing a 404).

Full code can be found here

  • The content directory can be found here
  • The autogenerated index.html can be found here

What I want to achieve:

  • Write jupyter notebooks and put them in the content/ folder organised by directory (ex. content/creating-data/notebook.ipynb)
  • Convert them to markdown/jekyll with running python make.py && python generate-html.py
  • Run hugo server and view index.html

Which should look something like this

But if I click on the link it gives me a 404 error.

image

This is what the markdown file looks like including it’s front matter.

---
layout: page
title: Loading_scikit_learn_iris_datset
permalink: /Loading_scikit_learn_iris_datset
---

# Loading scikit-learn Iris dataset

...

This is how I try to link to the page

                    {{ $section := site.GetPage "creating-data" }}
                    {{ range $section.RegularPagesRecursive }}
                    <ul>
                      <li>
                          <a href="{{.Permalink}}">{{.Title}}</a>
                       </li>
                    </ul>

What am I doing wrong? Please let me know if I need to give any additional information.

Kind regards,
Rainymood

This question has been asked many many times in the past.

Please search the forum about setting a baseURL with a subdirectory.

Also see the second bullet point of this section in the Hugo Themes README.

1 Like

Hi, thank you for the quick reply.

I really feel like I did a thorough search and experimented with trying out my own solutions before attempting to ask for help. The problem is that I am an extreme novice at Hugo (this is my first time trying to change anything but a default template) and am running into a lot of issues (which makes it hard to fix things because five things are breaking at the same time).

  • Make sure not to use a forward slash / in the beginning of a URL , because it will point to the host root and Hugo will not generate the correct URL for the demo’s assets.

I tried changing permalink: /Loading_scikit_learn_iris_datset to permalink: Loading_scikit_learn_iris_datset but that didn’t seem to fix it

What strikes me as odd is that sometimes the generated links do work and sometimes they don’t

Permalinks cannot be set the way you do it, their configuration is global and can be done in a project’s config.

In content files one can set either the url or slug values.

Also see:

At the moment I am away and unable to look into your project. I will have a look later.

url: /Loading_scikit_learn_iris_datset

This sets the full permalink of that page. If you wish to only change the part at the end and keep the automatic folder parts then slug is your friend.

Check the documentation on Fronmatter about details:

Hi Davids, thank you for your help.

When I add

url: /Loading_scikit_learn_iris_datset

To my frontmatter indeed the URL gets resolved to

http://localhost:1313/notes/Loading_scikit_learn_iris_datset/

instead of

http://localhost:1313/notes/folder-name/Loading_scikit_learn_iris_datset/

but it still throws a 404 error page not found.

I don’t know if this has anything to do with it but in my config.toml I have this setting

baseURL = "https://napsterinblue.github.io/notes/"

While I am developing it on localhost:1313. Do you think this could be an issue?

Regards, Jan


I have added another markdown file with the following contents, and this one it does seem to grab. So it has to do something with the front matter.

---
title: "Harris Corner Detector"
date: 2017-12-20T11:53:49-07:00
description: "How to detect corners images using OpenCV in Python with the Harris Corner Detector."
type: technical_note
draft: false
---

content

Your theme adds the baseURL in front of normal URLs. If your site is inside of the folder notes, that’s ok. If not, then the baseURL parameter should not have the notes part. Your repo is set up to be in the subfolder notes of your domain. So what Hugo does is right.

I am still very confused and unsure how to continue. Perhaps if I explain again what I want to achieve you can tell me whether there is any rhyme or reason to what I am doing

I have several markdown files that I want to display. They are structured in the content directory as follows

content
├── category
│   └── post.md
└── creating-data
    ├── Loading_scikit_learn_iris_datset.ipynb
    └── Loading_scikit_learn_iris_datset.md

Of course I only want to show the markdown files, and not the .ipynb files. I want to automatically group these into categories as displayed in the image below:

For the category creating-data I am using this code for that

    <div class="row">
        <div class="col-sm-12">
            <div class="card">
                <h4 class="card-header">creating-data</h4>
                <div class="card-body">
                    {{ $section := site.GetPage "creating-data" }}
                    {{ range $section.RegularPagesRecursive }}
                    <ul>
                    <li>
                      <a href="{{.Permalink}}">{{.Title}}</a>
                  </li>
                    </ul>
                    {{ end }}
                </div>
            </div>
        </div>
    </div>

I want to automatically generate this code above for each top level directory in content to automatically generate the tables to show the content.

Am I maybe grabbing the sections incorrectly?


In essence, I want to loop over my sections and then loop over the files in each section and show them in tables. That’s it. But it seems that my sections are empty.