Removing /post/ but keeping directory name in URL

tldr : How do I remove /post/ from url but keep /<directory>/<Filename> in URL

I created a hugo-netlify-forestry setup for my mother for her blog. She is writing her posts into a related folders
for example

/content/post
    --/Handloom/
                      -- katha.md
                      -- bandha.md
   --/History/Forts/
                     -- agra-fort.md
   --/History/Coins/
                    -- Mughal-coins.md

The url generated is missing-dots.in/post/Handlooms/katha She wants to remove the /post/ part of the URL so that final url would read missing-dots.in/Handlooms/<post>.

I tried using permalink in config, Since there is no :folder attribute, I tried using /:sections/:title but :sections includes the /post/ also. I deleted _index.md from the post folder and added _index.md in each folder but still that portion is not removed. I did that because docs said that folders with _index.md would be treated as a section by hugo. So I hoped that now hugo will not treat /post/ as section and only add the subsequent folders, But still the URL generated contains /post/

Forestry does not have a section to set url in front-matter, therefore currently when she uploads a post, I have to manually git pull it, add URL slug in the post, and push it. Is there a better way via config to do this. Is there a way to add :dir-path to the accepted attributes in permalinks?

permalinks:
  posts: /<directory>/:filename
3 Likes

Hi there! Thanks for linking to the required documentation page. I couldn’t find the other way to solve the issue for me. Thanks.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.