untra / polyglot

:abc: Multilingual and i18n support tool for Jekyll Blogs
https://polyglot.untra.io
MIT License
401 stars 59 forks source link

"Could not find document" when using "link" or "post_url" commands #91

Open cmcnicholas opened 6 years ago

cmcnicholas commented 6 years ago

Is the plugin intended to work when using Jekyll functions to generate links? An example below:

{% link _articles/activities/activities.en.md %}

This produces:

Liquid Exception: Could not find document '_articles/activities/activities.en.md' in tag 'link'. Make sure the document exists and the path is correct. in D:/Development/alloy-help/_posts/2017-07-10-assets.md
jekyll 3.4.3 | Error:  Could not find document '_articles/activities/activities.en.md' in tag 'link'.

Just to give some insight to our structure we have a collection called articles and sub directories of content. This was working fine before introducing the plugin and I would like to find a way to use the existing functions link and post_url if possible rather than in-lining the permalink.

I can confirm the file exists as well as a _articles/activities/activities.es.md

untra commented 6 years ago

Heya @cmcnicholas 👋

{% link _articles/activities/activities.en.md %}

Okay, so when you build the site, Polyglot will fork itself N times, one for each language you're building for. In each thread, it will then find the respective files starting from the directory matching it's assigned language, eg. /en/_articles/activities/activities.en.md . So in order to find your pages you will need to organize your _articles like this: with the default_lang files in the base directory, and the other _articles under the respective lang folders, like es, zh, etc.

I hope this helps 👍 you can also point me to your repo as well, and I'll clone it down to help further.

Cheers, Untra

cmcnicholas commented 6 years ago

Excellent, thanks for the quick response I will give this a try

untra commented 5 years ago

@cmcnicholas Did you have any luck with this? Otherwise I will close this issue.

cmcnicholas commented 5 years ago

Not yet pal, apologies for keeping the issue open been busy on some other products currently, I will try and make time this week and update the issue

evolverine commented 4 years ago

I'm having the same issue, but with pages instead of posts; and I have, indeed, tried the suggested organization of the _pages folder, but in _pages/pledge.md a link tag as such {% link _pages/about.md %} still throws a Liquid Exception, saying that it

Could not find document '_pages/about.md' in tag 'link'. Make sure the document exists and the path is correct. in _pages/pledge.md

Both _pages/about.md and _pages/ro/about.md exist, and they have the respective languages configured in the header (lang: en, lang: ro), plus the same permalink: /about.

george-gca commented 6 months ago

@untra this issue is not happening, but there is a deprecation warning. I am using it like this:

file: _posts/en-us/2023-07-12-post-bibliography.md

check the [distill style post]({% post_url 2018-12-22-distill %})

and the file _posts/en-us/2018-12-22-distill.md exists with the frontmatter as:

---
title: a distill-style blog post
date: 2018-12-22

in my config I set:

languages: ["en-us", "pt-br"]
default_lang: "en-us"
exclude_from_localization: ["assets"]
lang_from_path: true

The warning is:

Deprecation: A call to '{% post_url 2018-12-22-distill %}' did not match a post using the new matching
method of checking name (path-date-slug) equality. Please make sure that you change this tag to
match the post's name exactly.

But the link works as expected.