I use hugo to categorize and publish my notes.
There are example of my structure and URLs for every page which I want to get:
cat1 (URL: /cat1)
|-post1 (URL: /post1)
|-post2 (URL: /post2)
cat2 (URL: /cat2)
|-post3 (URL: /post3 URL)
|-post4 (URL: /post4 URL)
|-complexPost (URL: /complexPage)
|-subpage1 (URL: /complexPost/subpage1)
|-subpage2 (URL: /complexPost/subpage2)
|-complexPost2 (URL: /complexPage2)
|-subpage1 (URL: /complexPost2/subpage1)
|-subpage2 (URL: /complexPost2/subpage2)
Every post in my case is folder with index.md file and (optional) images.
I hear about “:filename” permalink variable, but it sets only “subpage1” for subpages, not full directory structure.
It is possible to remove main section from URL, and keep directory structure below?
Maybe I can write function for dinamical generating URL, which gets Page and return URL for this page?
You should create a Hugo project with your content structure, and then share it here with specific questions you have. Otherwise folks are just going to link to various docs that explain the concepts of permalinks and content structure.
My main project in russian and not ready for publish. =)
I created example structure, for demonstrate problem
For example page https://github.com/hugoFan1/example-site/tree/master/example/content/articles/mikrotik-pptp produces URL example+com/articles/mikrotik/. If I will write a lot of articles about microtik in future and move this articles into /content/mikrotik/ directory, then URL changes to example+com/mikrotik/mikrotik-pptp. I find way to avoid it (my main goal is stable URL).
I know it is possible to use “:filename” in permalinks. But it does not working with subpages. For example, page https://github.com/hugoFan1/example-site/tree/master/example/content/challenges/sicp have subpages 01, 02, 03. I want to get URL: example+com/sicp/01, example+com/sicp/02, example+com/sicp/03 for this pages.
Using “slug” parameter with every page is very difficult, because I have a hundreds articles. And It is redundantly, because slug is full copy of path in file system in my case.
I can write script for copy every 2-level subpage in /content directory. But it breaks setting “Type” and “Section” for my posts. I want to use this function.
It is completly no possible?
You can use
:sections, but it will give you the full section hierarchy, not the section directly above the content.
I need to remove only first section.
It is not possible to create function for generation page permalink?
Not that I know of.
As mentioned, you could use a
slug in your front matter to get what you want. Since you have many articles to edit, you could write a script that parses the file path of the content and then adds it to the