How to customize the theme/layout of the site?

64 views
Skip to first unread message

muhsan

unread,
Aug 1, 2019, 12:04:56 PM8/1/19
to nikola-discuss
Hi,
Sorry for the silly question--I am totally new to Nikola and web development in general.

So, I have generated a static website successfully using Nikola.  I would like to modify the website such that I can have the tags in the main page, and maybe add the number of posts corresponding to each tag (similar to the layout in this blog: https://meshlogic.github.io/).  

I am not sure where to start to making these changes? which folders? and files that I need to configure?  Could you guide me how to get started-- sort of lost when I tried reading the documentation. 

Thank you so much,

Chris Warrick

unread,
Aug 1, 2019, 4:48:06 PM8/1/19
to Nikola—Discuss
https://plugins.getnikola.com/v7/sidebar/

You would then need to create custom templates for pages that include
the sidebar with JavaScript or server-side includes.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

muhsan

unread,
Aug 8, 2019, 4:00:32 PM8/8/19
to nikola-discuss
I have installed the sidebar plugin and re-build the site, but I am getting this error message:

.  render_sidebar:output/sidebar-en.inc
TaskError - taskid:render_sidebar:output/sidebar-en.inc
PythonAction Error
Traceback (most recent call last):
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/doit/action.py", line 424, in execute
    returned_value
= self.py_callable(*self.args, **kwargs)
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/nikola/nikola.py", line 1370, in render_template
    template_name
, None, local_context)
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/nikola/plugins/template/jinja.py", line 96, in render_template
    data
= template.render(**context)
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
   
return original_render(self, *args, **kwargs)
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
   
return self.environment.handle_exception(exc_info, True)
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise
(exc_type, exc_value, tb)
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
   
raise value.with_traceback(tb)
 
File "/home/nikole_website/third_site/plugins/sidebar/templates/jinja/sidebar.tmpl", line 13, in top-level template code
   
{{ helper.list_posts(global_posts) }}
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/jinja2/runtime.py", line 579, in _invoke
    rv
= self._func(*arguments)
 
File "/home/nikole_website/third_site/plugins/sidebar/templates/jinja/sidebar-helper.tmpl", line 6, in template
   
{{ messages("Recent Posts", lang) }}
 
File "/home/.conda/envs/nikola_env/lib/python3.7/site-packages/nikola/utils.py", line 268, in __call__
   
return self[lang][key]
KeyError: 'Recent Posts'

########################################
render_sidebar:output/sidebar-en.inc <stdout>:


Not sure how to add the sidebar, could you please provide some insight.

Thanks, 

Chris Warrick

unread,
Aug 8, 2019, 6:06:52 PM8/8/19
to Nikola—Discuss
Please read that plugin's README file, you need to add translation strings to your site to use it.


--
Chris Warrick <https://chriswarrick.com/>
--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/2516726b-7599-4b25-be0a-842d4ce0d651%40googlegroups.com.

muhsan

unread,
Aug 9, 2019, 1:25:40 PM8/9/19
to nikola-discuss
Hi Chris: Apparently, when I re-build the site `sidebar-LANG.inc` could not be generated.  Could you tell me more about translation strings and how can they be used?  

I appreciate you assistance 
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-...@googlegroups.com.

Chris Warrick

unread,
Aug 9, 2019, 2:07:34 PM8/9/19
to Nikola—Discuss
You will need to add a `messages` folder to your theme, with a
`messages_en.py` file that contains the new messages. You can see the
built-in messages_en.py for reference:
https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/messages/messages_en.py
(You shouldn’t need all the strings in your copy, just the ones
required by the plugin).

You can alternatively modify the template for your sidebar not to use
translated strings.
> To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/1ce00e24-9fb6-4603-8620-d2b50a159e18%40googlegroups.com.

muhsan

unread,
Aug 9, 2019, 8:07:37 PM8/9/19
to nikola-discuss
I have created `messages` folder inside the corresponding theme, which I specified in `confg.py` file.  Here is the path where I have added `messages_en.py`
/my_site/themes/bootblog-jinja/messages/messages_en.py

Then, I re-build the site and got the same error; do I need to modify `messages_en.py` for the `sidebar` plugin, specifically? 

Thanks,

Chris Warrick

unread,
Aug 10, 2019, 10:26:56 AM8/10/19
to Nikola—Discuss
Did you read the README for the sidebar plugin?
> To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/daa82e99-2c5f-4137-b7bf-9b47833b64e7%40googlegroups.com.

muhsan

unread,
Aug 10, 2019, 12:16:15 PM8/10/19
to nikola-discuss
I am not fully following what is in the README.  I have understood that the site generator needs messages so the sidebar could be added to the site. 

The files residing under `./plugin/sidebar`: `sidebar.tmpl` and `sidebar-helper.tmpl` are also crucial for the generator to render a side bar.

I would appreciate it if you could you provide some pointers of what could be the issue.

Thanks,

Chris Warrick

unread,
Aug 10, 2019, 2:21:51 PM8/10/19
to Nikola—Discuss
On Sat, 10 Aug 2019 at 18:16, muhsan <mealb...@gmail.com> wrote:
>
> I am not fully following what is in the README. I have understood that the site generator needs messages so the sidebar could be added to the site.
>
> The files residing under `./plugin/sidebar`: `sidebar.tmpl` and `sidebar-helper.tmpl` are also crucial for the generator to render a side bar.
>
> I would appreciate it if you could you provide some pointers of what could be the issue.

Did you add the messages listed in the plugin’s README to your
messages_en.py file?

muhsan

unread,
Aug 10, 2019, 3:56:40 PM8/10/19
to nikola-discuss
I am using the sidebar plugin, and it looks like the messages listed in the README file are:  Recent posts, Archives, Categories, and Tags.  

I think I do have the `Archives`, `Categories`, and `Tags` messages in the `messages_en.py`.  I mean these, messages have a value pair associated with them, except `Recent posts` message.

Just realized that it seems the error message is raised because the Recent posts, message/translation, is missing in the `messages_en.py` file:

KeyError: 'Recent Posts'

How should I represent the `Recent Posts` message in the dictionary of messages?  I mean what will be the key-value pair? Is it as such:
`Recent Posts`: 'Recent Posts'

Chris Warrick

unread,
Aug 10, 2019, 4:39:26 PM8/10/19
to Nikola—Discuss
With regular quotes (" or ' but not `) on both sides, as you would do in any other Python dict, and the same way the existing entries look.


--
Chris Warrick <https://chriswarrick.com/>
--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/af65f162-fb02-49b3-a911-87131f2a7d6e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages