Franklin.pagevar("", :title)

After initialize a site using newsite("test"), in the interactive environment I ran the statement

Franklin.pagevar("", :title)

It throws the following error msg:

julia> Franklin.pagevar("", "title")
ERROR: KeyError: key :folder not found
 [1] getindex(t::OrderedCollections.LittleDict{Symbol, String, Vector{Symbol}, Vector{String}}, key::Symbol)
   @ Base .\abstractdict.jl:497
 [2] path
   @ C:\Users\zengc\.julia\packages\Franklin\AGBc8\src\utils\paths.jl:71 [inlined]
 [3] pagevar(rpath::String, name::String; default::Nothing)
   @ Franklin C:\Users\zengc\.julia\packages\Franklin\AGBc8\src\utils\vars.jl:261
 [4] pagevar(rpath::String, name::String)
   @ Franklin C:\Users\zengc\.julia\packages\Franklin\AGBc8\src\utils\vars.jl:246
 [5] top-level scope
   @ REPL[6]:1

I have to use pagevar in interactive environment for test purpose, but I have no idea how to solve this error. Could you @tlienart kindly give me some advices?

Franklin.pagevar("", :title) throws the same error.

Ok I understand you want to experiment with pagevar inside the REPL however you have to understand a little bit about how Franklin does stuff for this.

When calling serve, Franklin looks at the path (typically your current working directory) and builds a representation of paths that it keeps track of, namely the :folder (corresponds to the root where your website is) but also for instance :site which is the output path where files are written.

These paths are typically irrelevant for the users and so this is created upon starting serve and then cleaned up after serve has finished. So when you do pagevar after stopping a session, these paths are not defined anymore and so pagevar(...) doesn’t have the path hierarchy it needs in order to resolve paths.

There are two things you can do here:

  1. (probably what you want) run serve(...; single=true, cleanup=false) which will do a single pass to look at your site, build it, stop and will not clean things up so that you can inspect the various internals as you see fit (you can also check out Franklin.GLOBAL_VARS and Franklin.ALL_PAGE_VARS for instance to check the representation of page variable assignments)
  2. (probably what I would suggest) run serve(...) without specific keywords and experiment within a page while the server is running with {{fill var from}} so for instance {{fill title menu1}}

Thank you for your detailed explanation.