indeed for the use case mentioned the replies above are correct, pagevar
is what you want, there’s an example here: Franklin FAQ , you can see the source code here: https://github.com/tlienart/Franklin.jl/blob/5629fc51904f454b299c020f60061ca0701cafcc/demos/utils.jl#L41-L56
indeed all content is generated in __site
but if you want access to the state at the end of the generation process then there’s essentially two things you can look at (but that are not exposed and not really meant for the user to use, see also note about new version further down):
Franklin.GLOBAL_VARS
Franklin.LOCAL_VARS
if you do serve(..., cleanup=false)
these object will remain and you can inspect them.
GLOBAL_VARS
contains all the global variables as well as a bunch of general state variables that Franklin uses site-wide
LOCAL_VARS
is a temporary container for everything that’s used on a single page (local variables).
you should not use those directly, using globvar
, locvar
or pagevar
is the expected way to go to retrieve respectively a global variable, a local one (from the page on which it’s defined) or a local one from another page.
A note on the future
(I’m writing it for the sake of indicating that I’m well aware of the clunkiness of some of these things and that serious work has gone into re-designing it – if you’re curious you can test it out at Xranklin.jl).
In the future there’s one container for the global context (~ the GLOBAL_VARS
above) and a list of local containers for each of the individual contexts associated with each of the pages (~ the LOCAL_VARS
but keeping all of them). These containers are actually exposed to the user so you can do whatever you want with them and while the globvar
, locvar
, pagevar
api will remain, you can also directly interact with those containers.
If you’re wondering why this wasn’t the case in the first place, there’s a slightly tricky graph dependency problem with page variables. As soon as you allow pages to depend on other ones (e.g. query their page variables) then the order in which you process pages matters and, potentially, you may have to re-process some to be sure to have all the information.
Initially there wasn’t the possibility to query across pages, this was added (not very well), it kinda worked, then serious bugs started appearing, which required the introduction of the clunky @delay
macro which made sure that some pages were processed twice to ensure that dependencies were resolved, long story short it’s messy. One of the main improvement of the next version is to fix that stuff (and remove this @delay
thing).