Skip to content

Meta plugin does not configure blog post authors #6254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
nint8835 opened this issue Oct 29, 2023 · 3 comments
Closed
4 tasks done

Meta plugin does not configure blog post authors #6254

nint8835 opened this issue Oct 29, 2023 · 3 comments
Labels
bug Issue reports a bug 🏆 perfect Issue is of outstanding quality resolved Issue is resolved, yet unreleased if open

Comments

@nint8835
Copy link

Context

No response

Bug description

When attempting to set the default authors for blog posts via the meta plugin according to the docs, the authors do not actually show up on the blog posts. Non-blog metadata configured via the meta plugin (such as tags) will show up, so properties from the meta plugin are being applied to the file, but seemingly blog data is not.

This can be worked around by manually copy/pasting the meta contents into the frontmatter of each post.

Related links

Reproduction

9.4.7+insiders.4.42.3-meta-doesnt-set-authors.zip

Steps to reproduce

  1. Install dependencies
  2. Build the site with mkdocs build or serve it with mkdocs serve
  3. Navigate to the blog index. Observe that the post with the author explicitly set shows an author, but the post which should be using the author from the meta does not have an author shown.
  4. Navigate to the post without an author shown, and observe that there is a "Blog" tag shown at the top, showing that the meta file which should be configuring the author is applying to this file.

Browser

No response

Before submitting

@squidfunk squidfunk added the bug Issue reports a bug label Oct 30, 2023
@squidfunk
Copy link
Owner

squidfunk commented Oct 30, 2023

Thanks for reporting and providing the excellent reproduction. It made tracking down the root cause and solving further problems along the way straight forward. Fixed in 3ac702d. The problem:

The meta plugin collects meta files in on_files and then applies metadata in on_page_markdown, which is the first stage at which metadata is available. The problem is that for the blog plugin, this is too late, because the metadata of blog posts must be resolved in on_files before navigation is built, because we must remove files that are considered posts (i.e. hosted in the post_dir) as posts from navigation + we need to generate pages (archive, category indexes, pagination, etc.) in order to mount them at the correct position in the navigation. Getting the ordering with all of those constraints right is tricky, as one can see.

The commit fixes the following things:

  1. Correctly apply meta data of meta files to blog posts (as reported in OP)
  2. Deduplicate authors and categories, as merging might lead to duplicate authors or categories in lists
  3. Ensure that meta files are only applied once to every page

@squidfunk squidfunk added resolved Issue is resolved, yet unreleased if open 🏆 perfect Issue is of outstanding quality labels Oct 30, 2023
@nint8835
Copy link
Author

Tested on my site with the latest changes off the master branch and confirmed working - thanks for the quick fix!

@squidfunk
Copy link
Owner

Released as part of 9.4.8+insiders-4.43.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug 🏆 perfect Issue is of outstanding quality resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants