pollen start gives error if there are other directories
#40
Closed
opened 4 years ago by adamfeuer
·
11 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Hi,
I want to have some javascript and css static files in my pollen content directory so that the web pages render correctly. These are from Zurb Foundation Sites. When pollen tries to compile the project, I get an error, see below.
My directory layout is like this:
How can I use the pollen webserver and also have static css and js at the same paths that they would be when published...?
I created a small publish script that does pollen render to an output directory, and then copies in the css and js static files which I can serve using npm. This works, but it requires the additional manual step to run the publish script.
Here's the error:
The error message refers to
js1
but there’s no file calledjs1
in your project. Could this error be the result of a typo inindex.html.pm
ortemplate.html.p
?I had been trying different things, creating a
js1
directory instead of symlinks, so that directory did exist, I made a mistake entering the layout above. If I remove the directoryjs1
to make the directory conform to the layout above, I get the same error:If
content
is essentially a mirror of your public web directory, then to simulate the live environment, you’d want to a) start the project server fromcontent
as the top-level directory, and b) usually it’s easiest to use absolute URLs to refer to CSS and JS resources located near the top. For instance, intemplate.html.p
you would refer to"/js/app.js"
and"/css/app.css"
— these URLs would work in the project server, and also in your public directory, since it has the same structure.Here's an excerpt of what's in
content/template.p
:So it seems like I'm doing what you are suggesting. But why am I getting a rendering error? It seems like pollen doesn't like something about these directories.
Note that if I remove the
css
andjs
directories, I can render using theraco pollen start
webserver, but the HTML won't be displayed right in my web browser; or I can render to a separate output dir via my script, and then add thecss
andjs
directories back in.Perhaps you can show your
to make it easier to debug?
@sorawee Thanks, here's the files:
index.html.pm:
pollen.rkt
template.html.p
@sorawee @mbutterick If I remove the
css
andjs
dirs, I get this error from the web server, pollen seems like it's reading the links in the HTML and trying to find and render pollen files. Then it fails, and reads from cache.Is there a way to tell the pollen web server that these are static directories? So it won't try to render them?
The problem, I think, is due to the use of
◊(select 'h1 prev-page)
and◊(select 'h1 next-page)
in yourtemplate.html.p
. Since you didn't defineindex.ptree
, Pollen automatically generates one for you, which contains non-Pollen files. Therefore, the lookup forh1
fail.So either create
index.ptree
that contains only Pollen files, or if you don't actually want the previous and next links, just remove:from your
template.html.p
.See https://docs.racket-lang.org/pollen/second-tutorial.html#%28part.tutorial-2..Pagetrees%29 for more details about the pagetree file.
I get the same errors as you (because I am missing the files — those are the errors I would expect). When I create stub files in the
"js"
and"css"
directories that match those filenames, the errors go away (as I also expect).There isn’t a fixed boundary between “static directories” and others. Suppose you link to a file
"/dir/src.js"
. If it exists as a static file, the project server uses that. If it doesn’t, the project server looks for a corresponding Pollen source file, renders it, and serves the result.In other words, a directory of static web files is itself a valid Pollen project and ought to function normally without any need for further configuration.
@sorawee You're right, it was the lack of a pagetree file. I will want the previous and next links when I expand my book, so having the pagetree is necessary. I created this:
And now I can use the pollen server with my static css and js files.
Thank you @sorawee and @mbutterick for the help!