Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pelican CSS Path

Random little pelican problem if anyone can help me.

I am writing a theme which is structures like this.

├── static
│   ├── css
│   ├── js
│   └── img
└── templates
    ├── index.html
    └── page.html

In the index.html file I'm using this to call the static css, img and js files

<link rel="stylesheet" href="theme/css/base.css"/>

For the page.html I then 'extend' the base.html with this line

{% extends "index.html" %}

When I generate the html in to the output folder all works fine for the index.html but the page.html can't find the static files as it will need a new path. This is the output folder setup.

├── theme
|   ├── css
│   ├── js
│   └── img
├── index.html
└── pages
    └── page.html

If you see the page.html can't load the css by using the path theme/css/base.css

Is there a way to use a {{ ROUTE }} command when loading static files?

Thanks!

Edit 1 After looking at some other theme's index.html page on Github I see they use the {{ SITEURL }} tag but that doesn't work for me.

<link rel="stylesheet" href="{{ SITEURL }}theme/css/base.css"/>

Edit 2 I've fixed this by using the following line in the pelicanconf.py file

RELATIVE_URLS = True

and the following in index.html

<link rel="stylesheet" href="{{ SITEURL }}/theme/css/base.css"/>
like image 789
Spinnaay Avatar asked Oct 29 '22 18:10

Spinnaay


1 Answers

I had the same issue when developing locally and was able to resolve it by setting SITEURL = '.'.

like image 54
J. Wright Avatar answered Nov 15 '22 07:11

J. Wright