Specifying/understanding the rendering order for content

I’m trying to figure out the right way to construct a new project. I’ll ask a general question and get to the specifics a bit later.

The general question: How do I know the order in which pages are rendered and is there a way that I can ensure that certain pages are rendered before others?

Background. I’m not a Ruby/JS pro, I cut my teeth on C/C++/ASM and embedded systems. But, I’ve been building Jekyll sites since the early 2010’s for work and fun. For the last 5+ years, nearly everything new is done with a fork of minimal-mistakes that I maintain and I merge (non-bot) upstream changes occasionally as @mmistakes makes them. I use the local-theme plugin for developing with the theme as a git submodule in _themes. For production, I have the typical github build/deploy action with the remote-theme plugin pointing to my fork.

The details. I have about 100 Markdown files in _posts that are rendered by a custom layout that pulls in some externally-generated text. The lunr.js plugin seems to run prior to these pages are completely rendered, so the search index does not have the external text. This text does appear in the final site. Is there a way to specify that lunr.js runs after the other pages are fully rendered so that I can get this text in the search index?

I know I can go to a more powerful search engine, use google, algolia, etc. The Algolia plugin runs post-build and that’s nice, but it’s not going to be an option for the contract that I am working on. There isn’t a great deal of text, so lunr will be fine. Also, it’s pretty obvious that Algolia isn’t supporting the tools for jekyll and their community support is pretty much gone now. Google may eventually be an option, but currently the site is behind a firewall and may or may not see the light of day for a public scan of the content. I’m open to other lightweight search options that don’t involve an enterprise contract.

Thanks!