lektor / lektor-tags

For each tag on your site, build a list of pages with that tag. This can be used for standard tag-based blog navigation.
MIT License
27 stars 6 forks source link

Pages are not processed recursively #14

Open paternal opened 6 years ago

paternal commented 6 years ago

The README says that in the config file, parent = / is allowed. However, if I set so (I would like my tags to be located at http://example.com/tag instead of http://example.com/blog/tag):

How can I make lektor-tags work with parent = /?

nixjdm commented 6 years ago

To do this you need to set these:

parent = /
url_path = {{ this.parent.url_path }}{{ tag }}

and then reference that tag pages as just {{ ('/' ~ t.lower())|url }}, or I think {{ ('/@/' ~ t.lower())|url }} if you have pagination on your root page. I haven't tested that last bit though.

This will allow you to tag all children of the root page, and have tag pages generated as their siblings. The parent is indirectly defining the pages that can be tagged, and the url_path is defining where the tags' pages go.

A caution: I'm not sure what will happen if names conflict, but it is surely something to watch out for. The default url_path inserts a tag/ with {{ this.parent.url_path }}tag/{{ tag }} partly to bypass that problem.

nixjdm commented 6 years ago

For example: https://github.com/terminal-labs/lektor-jinja-content/tree/master/tests/demo-project

paternal commented 6 years ago

In the example you gave, the links are correctly produced (although I would prefer /tag/tag1 and /tag/tag2 rather than /tag1 and /tag2, but I think I can change that with the url_path config option (maybe my original question was unclear)), but some of the pages tag1.html and tag2.html are not created, so the links (to the tag pages) are dead.

Pages tag1.html and tag2.html are not created (those are the tags of the root page), while page tag.html is created (which is the tag of the subpage). Why one is created, while the other are not?

Tested using Lektor 3.1.2.

paternal commented 6 years ago

And I have to dig a little further (I will keep you updated), but on my website, using the same configuration as your example, not a single tag page is created (and no error is displayed or raised).

paternal commented 2 years ago

Four years later… Did I procrastinate?

With your advice, no tag page is generated…

I set up a repository with a very simple lektor website : https://github.com/paternal/lektor-tags-mwe

Other bugs (or behavior I don't understand):

Everything is done on a debian testing, in a virtualenv, with python 3.10.5 and lektor 3.3.4.

paternal commented 2 years ago

🎉 I GOT THE CULPRIT ! 🎉

The issue is that with parent = / in the configs/tags.ini, tags defined in first level pages (e.g. /content/foo/contents.lr) are correctly handled (their corresponding tag page is created), but tags defined in second level pages or below (e.g. /content/foo/bar/contents.lr) are broken (their corresponding tag page is not created).

I have witnessed this behavior in your demo project, in my minimum working example, as well as in my real project.

paternal commented 2 years ago

🎉 I GOT THE CULPRIT ! (AGAIN) 🎉

Since the beginning, I assumed that pages were processed recursively, while only the children of the parent page (defined with option parent in the configuration file) are processed.

nixjdm commented 2 years ago

@paternal Good finds. I think you should check out the discussion on https://github.com/lektor/lektor/issues/445 and see what you think.