Open nathancatania opened 11 months ago
I'm having the same error, please help! Big thanks!
Yes this is a known incompatibility unfortunately, mkdocs-material broke support when they rewrote the blog plugin and I've been unable to fix that since.
That's on my TODO list but can't share any ETA tbh.
I just added an if
:
if file.page:
file.page._set_canonical_url(mkdocs_config.get('site_url', None))
This makes the build succeed but the blog is still empty.
I have met the same problem. I can successfully build the site, but the blog part is empty.
In the Gothic Modding Community we finally decided we need the blog plugin to allow for more flexibility when adding non-documentation pages. We kept putting it off, because of the incompatibility here. However, one of the maintainers mentioned that our website is used primarily by the default
(English) language users, so why don't we just create a non-i18n default language blog hack. So if you're interested in the same thing, adding an option to blog in your default language, then here you go. I'm still working on the PR for our project, which you can see here:
Here is the extracted hook from all of my hacky changes:
Here is a mini example I tested:
Reference:
[!NOTE] I updated the hook above after the initial comment, so please update it if you used it :v:
For the blog I am fine with the default language too so this is really great. Thanks so much for sharing!
Since it occured to me too, you need to update to the latest i18n, mkdocs and material for above script to work.
@kamilkrzyskow I tried your script, and it can solve the part problem. Without using the hook script, the blog of my site is empty. After using the hook script, the blog can render correctly.
But it displays blogs in all languages simultaneously. Normally, when I choose English, the page only displays the English version of the blog. I choose Chinese, and the page only displays the Chinese version of the blog.
Here is a mini example I tested: i18n-with-default-blog.zip
Hi @SWHL, you have misunderstood. The purpose of this hook is to only allow to add default language posts, and they'll will be added for every language.
Currently the i18n plugin doesn't support the blog plugin at all, so it's empty, no posts are shown. This hook allows to add files and make them display. So do not add multiple languages for blog posts, only add one language, preferably the default language.
❗ This hook doesn't fix the lack of i18n support for the blog, via this plugin.
@kamilkrzyskow Thank you for your reply, I did misunderstand.
Tested with mkdocs-static.i18n 1.2.0 and mkdocs-material 9.5.2-insiders.4.47.1:
Whenever I add the
blog
plugin with a post, I get the following error attempting to runmkdocs serve
:site_url
is definitely set in my mkdocs.yml:janvanveldhuizen has the same issue as per this comment: https://github.com/ultrabug/mkdocs-static-i18n/pull/268#issuecomment-1825246468