eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.46k stars 314 forks source link

Cannot use {% url path %} in blog posts #234

Closed blattms closed 7 years ago

blattms commented 8 years ago

Using {% url path %} in blog posts results in the following error:

*** Error while building
'__CACTUS_SITE__'
Traceback (most recent call last):
...
File "/usr/local/lib/python2.7/dist-packages/Cactus-3.3.2-py2.7.egg/cactus/template_tags.py", line 52, in url
    site = context['__CACTUS_SITE__']
  File "/usr/local/lib/python2.7/dist-packages/Django-1.6.11-py2.7.egg/django/template/context.py", line 56, in __getitem__
    raise KeyError(key)
KeyError: '__CACTUS_SITE__'
dwightgunning commented 8 years ago

Try modifiying the blog.py plugin to add the "page" to the blog post context dictionary.

# Build a context for each post
postContext = {}
postContext['page'] = page

You can then use {% url page.url %} in the templates.

blattms commented 7 years ago

Should be resolved due to the merge of #229