Basic tinkering

58 views
Skip to first unread message

sll

unread,
Oct 17, 2020, 5:13:28 AM10/17/20
to sphinx-users
Hi,

I'm new here.

If I start a project (Alabaster theme), how could I do things like deleting the word "Navigation" from the sidebar?

Thanks

Matt from Documatt

unread,
Oct 19, 2020, 9:06:22 AM10/19/20
to sphinx...@googlegroups.com
It would be best if you learned a little about Sphinx themes. Themes contain templates like layout.html for page.html for regular documents, search.html for search results, etc. The most important template is layout.html. Templates contain blocks that are the smallest customizable parts. Based on your question, you want to override block "relbar1" in layout.html.

Have a look at https://documatt.gitlab.io/sphinx-themes/learn_basic_theme_project/ to learn layout.html blocks.

The official documentation has an excellent description and examples of overriding blocks: https://www.sphinx-doc.org/en/master/templating.html#jinja-sphinx-templating-primer.

I recently blogged about this topic, too, at https://techwriter.documatt.com/sphinx-theming/index.html. Feel free to ask here!

Matt
Message has been deleted

sll

unread,
Oct 24, 2020, 12:51:33 PM10/24/20
to sphinx-users
 @Matt, thank you very much for your help!!

But unfortunately I'm still very much lost.

I went into /usr/share/sphinx/themes/basic/layout.html (I think that's the one I have to play with because of something I read about inheritance) but there I only found an empty block named relbar1:

{%- block relbar1 %}{{ relbar() }}{% endblock %}

But I did find a part with a similar name and containing "Navigation":

{%- macro relbar() %}
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>{{ _('Navigation') }}</h3>
      <ul>
        {%- for rellink in rellinks %}
        <li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}>
          <a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags|e }}"
             {{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
          {%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
        {%- endfor %}
        {%- block rootrellink %}
        <li class="nav-item nav-item-0"><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
        {%- endblock %}
        {%- for parent in parents %}
          <li class="nav-item nav-item-{{ loop.index }}"><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
        {%- endfor %}
        {%- block relbaritems %} {% endblock %}
      </ul>
    </div>
{%- endmacro %}


So I decided to try with it. I copied all that part, but only that one, and pasted it into a new file. I saved the file as ~/mySphinxProject/_templates/layout.html (If I understood correctly that is the path and name it must have, please correct me if I am wrong).

On that new file, I replaced the following line

      <h3>{{ _('Navigation') }}</h3>
with
      <h3>{{ _('xxx') }}</h3>

After running make html, my output disappear, the webpage was completely empty.

I deleted  ~/mySphinxProject/_templates/layout.html but I keep having no output at all, the wepage is still completely white.

I might be making more than one mistake... Any help is very much welcome!

By the way, what and where is something named templates_path ?
Reply all
Reply to author
Forward
0 new messages