# Emulating Jekyll Permalinks

**URL:** <https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891>\
**Category:** support\
**Created:** [August 28, 2018, 6:01pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891 "2018-08-28T18:01:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [August 28, 2018, 6:01pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/1 "2018-08-28T18:01:37Z")

</div>

I’m converting a moderately large site from jekyll to Hugo. I need to maintain my permalinks for disqus and the large number of external links to content.

The jekyll path is: baseurl/category/year/month/day/title.html

I’ve come close to this with the following config:

```
permalinks:
  posts: /:year/:month/:day/:title/
uglyurls: true

```

However this renders my permalinks as: baseurl/year/month/day/title.html

Note the missing “category” in the path.

Obviously jekyll views what a ‘category’ is differently than Hugo, however I still need to maintain these permalinks for previous posts.

Is there a way to do this with Hugo?

Otherwise I assume my option is to just write script that parses the category in the post, and moves it to /content/posts/category/. I may do this regardless, but I view this as a situation to learn more about Hugo.

---

<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:** [August 28, 2018, 6:09pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/2 "2018-08-28T18:09:16Z")

</div>

Is the `category` name same as the folder where the content files are placed?

If yes you could use the `/:section/` variable in your permalinks to have that category in the `.Permalink`

If no Hugo has a `/:slug/` variable and a `/:filename/` variable that you could use to pass the category.

Also for simple markdown content files Hugo supports extracting the date from the filename (however that is not currently possible for Page Bundles there is a GitHub issue about it).

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [August 28, 2018, 6:17pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/3 "2018-08-28T18:17:23Z")

</div>

No. All the posts are in /posts/

Are you saying that I would need to change the “category: thing” in each file to “slug: thing” then use :slug?

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [August 28, 2018, 6:31pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/4 "2018-08-28T18:31:59Z")

</div>

As a note, I wrote a script real quick that takes the “category: thing” and moves the posts to /content/posts/thing/filename

However when using “/:section/:year/:month/:day/:filename/” the permalink shows as “/posts/year/month/day/filename”

I would expect it to go to “/thing/year/month/day/filename” or even perhaps “posts/thing/year/month/day/filename”.

Am I misunderstanding how :section works?

---

<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:** [August 28, 2018, 6:36pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/5 "2018-08-28T18:36:38Z")

</div>

> [@AdmiralBumbleBee](#):
>
> Am I misunderstanding how :section works?

`:section` represents only the top level Section in this case `posts`

`:sections` is probably what you would want to use since it represents the content’s sections hierarchy.

See

> **[URL management](https://gohugo.io/content-management/urls/#permalink-configuration-values)**
>
> Control the structure and appearance of URLs through front matter entries and settings in your site configuration.

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [August 28, 2018, 6:46pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/6 "2018-08-28T18:46:03Z")

</div>

I just tried :sections and it still is showing “/posts/etc…”

I have the following:

```
permalinks:
  posts: /:sections/:year/:month/:day/:filename/

```

and the posts are showing up at /posts/year/month/day/filename

The posts itself are under /posts/category/ where category is the category.

Here is a concrete example:

On disk I have this: /posts/general/2017-06-27-Mobile-Updates

With the permalinks as written above, this is the url I’m getting: [http://baseurl/posts/2017/06/27/2017-06-27-Mobile-Updates.html](http://baseurl/posts/2017/06/27/2017-06-27-Mobile-Updates.html)

Everything past the year (2017) is correct for what I need. However I’m trying to get it to do this: [http://baseurl/general/2017/06/27/2017-06-27-Mobile-Updates.html](http://baseurl/general/2017/06/27/2017-06-27-Mobile-Updates.html) while maintaining the content/posts directory.

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [August 30, 2018, 3:29pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/7 "2018-08-30T15:29:14Z")

</div>

Any further ideas on this?

---

<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:** [August 30, 2018, 4:27pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/8 "2018-08-30T16:27:42Z")

</div>

How many categories are you looking into migrating?

Also what you want to do is a hard problem. I admit that when I first replied I hadn’t quite realized that what you’re really asking is a way to override the name of a section from the Permalinks.

If you search the forum with the above keywords you will see that this issue has come up before like over [here](https://discourse.gohugo.io/t/override-section-url/6197/3)

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [August 30, 2018, 4:29pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/9 "2018-08-30T16:29:57Z")

</div>

I’m looking to migrating around 50 categories.

Thank you for the link. I’ll investigate that as well.

---

<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:** [August 30, 2018, 4:34pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/10 "2018-08-30T16:34:28Z")

</div>

That’s quite a lot of categories for you to configure their permalinks.

In any case I submitted a [PR](https://github.com/gohugoio/hugoDocs/pull/584) in the Hugo Docs repo for Nested Taxonomies, you might find parts of it useful for your use case.

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [August 30, 2018, 4:37pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/11 "2018-08-30T16:37:48Z")

</div>

Awesome, thank you very much. Looking at the commit, it appears that I should be able to write a script that generates the necessary setup for me.

If/When I get this working, I’l update the topic with my solution.

---

<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:** [August 30, 2018, 4:38pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/12 "2018-08-30T16:38:49Z")

</div>

Please do update if you come up with a solution. It will help others.

Thanks!

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [September 3, 2018, 4:32am UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/13 "2018-09-03T04:32:12Z")

</div>

I have still been unable to solve this.

I attempted to create the new taxonomies and permalinks as explained in the pull request content, however they weren’t recognized at all, even when adding that data to the frontmatter of every post. Hugo still seems to regard the directory as priority for URL generation.

HOWEVER. In the docs at: [URL management | Hugo](https://gohugo.io/content-management/urls/#permalinks) under “Permalinks configuration example” It says:

> Only the content under `post/` will have the new URL structure. For example, the file `content/post/sample-entry.md` with `date: 2017-02-27T19:20:00-05:00` in its front matter will render to `public/2017/02/sample-entry/index.html` at build time and therefore be reachable at `https://example.com/2017/02/sample-entry/` .

This is not my experience. With that example the content ends up at `https://example.com/posts/2017/02/sample-entry/`. Note the “posts/” addition.

The result that the documentation gives is exactly what I want. What hugo actually does is not.

So at this point I’m assuming that the documentation is incorrect and that there may be no way to do this and still have my content under the content/posts/ directory locally.

**To explain what I want again (for anyone that doesn’t want to scroll up).**

I have content at `content/posts/sample-entry.md` with `category: diatribe" and a date of February 1st, 2017. I need this to be generated as: `[https://example.com/diatribe/2017/02/01/sample-entry.md`](https://example.com/diatribe/2017/02/01/sample-entry.md%60)

No matter what I seem to do, I end up with /posts/ in my generated permalink.

If I sort all my posts in to /content/category/ and add over 50+ “permalink: category: /:section/:year/:month/:day/:filename/” with "uglyurls: true"in my config… then it works. However it’s a total mess in both my config file and for local organization.

(However, “uglyurls: true” breaks other parts of my site… [Tags and Categories are rendered without index.html - #2 by AdmiralBumbleBee](https://discourse.gohugo.io/t/tags-and-categories-are-rendered-without-index-html/13893/2))

My site is active and live using Jekyll currently, and it’s very important that my permalinks stay the same for the content currently online.

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [October 8, 2018, 7:33pm UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/14 "2018-10-08T19:33:34Z")

</div>

A desperation bump.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [October 9, 2018, 12:40am UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/15 "2018-10-09T00:40:10Z")

</div>

Let’s see your project, maybe something can be done.

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [October 9, 2018, 12:45am UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/16 "2018-10-09T00:45:11Z")

</div>

I’m sorry, but it is huge and private.

You can assume a default jekyll setup in regards to how paths and files are generated.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [October 9, 2018, 12:47am UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/17 "2018-10-09T00:47:18Z")

</div>

> [@AdmiralBumbleBee](#):
>
> You can assume a default jekyll setup in regards to how paths and files are generated.

I don’t use Jekyll. Anyhow, you can set the URL per piece of content. Good luck! 🙂

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [October 9, 2018, 12:49am UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/18 "2018-10-09T00:49:48Z")

</div>

Setting per post permalinks, or projectwide does not seem to work as I outlined above.

I can put together a small project to demonstrate the issue.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [October 9, 2018, 12:51am UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/19 "2018-10-09T00:51:07Z")

</div>

Go for it! I may not have an answer for your pattern, but I can troubleshoot general permalink wonkiness. 🙂

---

<div class="post-metadata">

**Author:** ![AdmiralBumbleBee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/admiralbumblebee/32/6766_2.png) [@AdmiralBumbleBee](https://discourse.gohugo.io/u/AdmiralBumbleBee)\
**Post date:** [October 9, 2018, 1:16am UTC](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891/20 "2018-10-09T01:16:08Z")

</div>

Actually… using per-post aliases seems to work. I just need to write a script to add this to each post I think?

I will report back as I progress with this. I need to investigate a few other things.

Thank you for the idea maiki.

[Next page](https://discourse.gohugo.io/t/emulating-jekyll-permalinks/13891.md?page=2)
