On 5 July 2016 at 17:27, Paraplegic Racehorse
<
paraplegic...@gmail.com> wrote:
>
>
> On Mon, Jul 4, 2016 at 10:23 AM, Chris Warrick <
kwpo...@gmail.com> wrote:
>>
>>
>> PAGES = [
>> …
>> ("projects/*.rst", "projects", "project.tmpl"),
>> …
>> ]
>>
>> This takes all files that match the pattern "projects/*.rst" (0) and
>> render them in output/projects (1) using project.tmpl (2) as the
>> template.
>
>
> Okay. Now that makes sense. Oof. While it's nice to have documentation in
> conf.py, that's not the first place I go looking. The Handbook is. Maybe I
> need to fork the website repo and see what I can do about that...
>
The handbook lives in the main Nikola repo. It actually contains this
quote, but maybe we should have some description of how Nikola works
attached to that?
> Anyway, earlier you said:
>> You can do `nikola new_page`, but you will need to create a special
>> template for those, or at least change URL_TYPE to root-relative or
>> absolute URLs. Example:
>
> and I looked at your examples and still couldn't figure it out until I went
> back and saw 'URL_TYPE', so I looked at your conf.py on github and now it
> makes sense.
URL_TYPE = 'full_path' is necessary only if you want to access pages
and resources from your 404 page (which you usually do, unless you
inline CSS and images*)
Consider this directory tree:
|- logo.png
|- err
|- 404.html
With URL_TYPE = 'rel_path': (default)
<img src="../logo.png">
This will break if the URL will be further than one directory — that
is, /foo and /foo/bar will display it correctly, but /foo/bar/baz will
NOT display your logo. The <base> tag might actually fix it if enabled
— you could try leaving it that way…
With URL_TYPE = 'full_path':
<img src="/logo.png">
WITH URL_TYPE = 'absolute':
<img src="
https://example.com/logo.png">
No issues with either.
> BUT, if I set .. pretty_url: false in my 404 page created with
> new_page and set the slug to 404 I still don't get my 404 when I type in a
> page known not to exist. Is this expected behavior when URL_TYPE remains
> rel_path, rather than absolute? I guess what's really bugging me is how
> you're getting /output/err/[errorpage]/index.html to show up at the web
> root? I don't see it anywhere in the files or template or conf. Do you have
> a 301 redirect set up? Do 301 redirects even work with error pages?
Nikola does NOT handle your error pages. This depends solely on your
web server. I’m using nginx and so this is my server config:
error_page 403 /err/403/index.html;
error_page 404 /err/404/index.html;
error_page 500 /err/500/index.html;
error_page 503 /err/503/index.html;
If you’re using Apache:
https://httpd.apache.org/docs/2.4/custom-error.html
If you’re using GitHub Pages: make sure it becomes /404.html (no
pretty URL and middle thing in PAGES is an empty string) — cf.
https://help.github.com/articles/creating-a-custom-404-page-for-your-github-pages-site/
If you’re using some other web server/hosting provider: check the docs
* I actually have self-contained error pages (with the logo as base64
and CSS inlined), but I’m not a fan of relative paths.