# Permalinks not working, converting jupyter notebooks to hugo blog posts

**URL:** <https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950>\
**Category:** support\
**Created:** [March 25, 2021, 9:33am UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950 "2021-03-25T09:33:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rainymood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rainymood/32/13946_2.png) [@Rainymood](https://discourse.gohugo.io/u/Rainymood)\
**Post date:** [March 25, 2021, 9:33am UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/1 "2021-03-25T09:33:50Z")

</div>

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](https://github.com/Rainymood/notes)

- The content directory can be found [here](https://github.com/Rainymood/notes/tree/master/content)
- The autogenerated `index.html` can be found [here](https://github.com/Rainymood/notes/blob/master/themes/berbera/layouts/index.html)

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

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/0/079bfc945236f547ceb85f590ce9f984b05a0934.png)

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

![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/9/9ff6661f31416510be28b848da3fb8eaeb296346.png)

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

```auto
---
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

```auto
                    {{ $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

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [March 25, 2021, 10:24am UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/2 "2021-03-25T10:24:49Z")

</div>

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](https://github.com/gohugoio/hugoThemes#common-permalink-issues) in the Hugo Themes README.

---

<div class="post-metadata">

**Author:** ![Rainymood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rainymood/32/13946_2.png) [@Rainymood](https://discourse.gohugo.io/u/Rainymood)\
**Post date:** [March 25, 2021, 10:32am UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/3 "2021-03-25T10:32:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [March 25, 2021, 11:18am UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/4 "2021-03-25T11:18:13Z")

</div>

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:

> **[URL Management](https://gohugo.io/content-management/urls/#permalinks)**
>
> Hugo supports permalinks, aliases, link canonicalization, and multiple options for handling relative vs absolute URLs.

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

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 25, 2021, 12:25pm UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/5 "2021-03-25T12:25:31Z")

</div>

> [@Rainymood](#):
>
> `permalink: /Loading_scikit_learn_iris_datset`

```auto
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:

> **[Front matter](https://gohugo.io/content-management/front-matter/)**
>
> Hugo allows you to add front matter in yaml, toml, or json to your content files.

---

<div class="post-metadata">

**Author:** ![Rainymood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rainymood/32/13946_2.png) [@Rainymood](https://discourse.gohugo.io/u/Rainymood)\
**Post date:** [March 25, 2021, 2:28pm UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/6 "2021-03-25T14:28:08Z")

</div>

> [@davidsneighbour](#):
>
> ```auto
> url: /Loading_scikit_learn_iris_datset
> 
> ```

Hi Davids, thank you for your help.

When I add

```auto
url: /Loading_scikit_learn_iris_datset

```

To my frontmatter indeed the URL gets resolved to

```auto
http://localhost:1313/notes/Loading_scikit_learn_iris_datset/

```

instead of

```auto
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

```auto
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.

```auto
---
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

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 25, 2021, 2:51pm UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/7 "2021-03-25T14:51:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rainymood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rainymood/32/13946_2.png) [@Rainymood](https://discourse.gohugo.io/u/Rainymood)\
**Post date:** [March 25, 2021, 3:01pm UTC](https://discourse.gohugo.io/t/permalinks-not-working-converting-jupyter-notebooks-to-hugo-blog-posts/31950/8 "2021-03-25T15:01:28Z")

</div>

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

```auto
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:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/3/3bf6f3bd4e4f61c5b144661f3ccfa5ff9bcbd24e.png)

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

```auto
    <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.
