Only recompile PDFs if MD content has changed

14 views
Skip to first unread message

S. Qiouyi Lu

unread,
Aug 24, 2023, 9:48:05 PM8/24/23
to nanoc
Hi all! Question that I didn't seem to find an answer to in the documentation:

Currently I'm using a modified version of the Create PDFs guide: https://nanoc.app/doc/guides/creating-pdfs/

The PDFs are generating fine. However, the problem is that, whenever I change layout files that apply to Markdown documents, the PDFs will *all* recompile even if the content of the MD file did not change. The workflow appears to assume that layouting the file changes the contents, which is not the case.

I would like to set the PDFs to recompile only if the Markdown file has changed, regardless of whether any layouting has changed in the output. There seems to be a point in the workflow when I can compare pre-layouted files to check for changes, but I'm not sure how to implement this (I'm new to Ruby).

Currently compiling the website takes 18 seconds if PDFs are recompiled, but like 1 or 2 seconds without PDFs recompiled. The number of documents to be compiled to PDF will only increase, so I want to catch this before it becomes a real problem.

Thanks,
S.
(they/them)

Denis Defreyne

unread,
Aug 30, 2023, 7:13:31 AM8/30/23
to na...@googlegroups.com
Hey S,

Nanoc generally tries to not recompile pages that don’t need to be, but it also errs on the side of caution and recompiles when it’s not 100% sure.

My suspicion is that there are some unexpected/incidental dependencies from the PDF file onto other items, and those dependencies trigger an undesirable recompilation of the PDF files.

You can use the `nanoc show-data` command to show the status of all the items in the site. It’s a lot of data, especially on larger sites. What you’ll likely be most interested in is the item dependencies (all the way at the top of th eoutput), which shows which items depend on which other items/layouts. Also interesting is the outdatedness reasons for each item, near the bottom of the output.

This could give you an idea of what unexpected dependencies exist. Then, if you’re able to identify those, you might be able to cut them, so that PDFs only get regenerated when they’re absolutely necessary.

Can you let me know how that works? Feel free to share your site source and the output of `nanoc show-data` as well if you’re struggling.

Best,

--
You received this message because you are subscribed to the Google Groups "nanoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanoc+un...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages