Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Info] Change template for index.html #155

Open
himito opened this issue Mar 22, 2017 · 4 comments
Open

[Info] Change template for index.html #155

himito opened this issue Mar 22, 2017 · 4 comments

Comments

@himito
Copy link

himito commented Mar 22, 2017

Hello,

I would like to change the template only for the index.html. There is a way to do that ?

Thank you in advance !

@ryan-roemer
Copy link
Owner

Not sure offhand -- that's more of a "sphinx" general thing than a "sphinx bootstrap theme" thing. Perhaps the official sphinx docs can help you?

@himito
Copy link
Author

himito commented Mar 22, 2017

Thank you for your help !

@iwelch82
Copy link

iwelch82 commented Apr 5, 2018

This can be be done by adding a layout.html file to your _templates directory that extends the bootstrap file.
I was able to modify the template, only for the index.html, by adding the following

{% if pagename == "index" %}
  <your HTML goes here>
{% endif %}

Here is all my code. My goal was to add a banner image and title so I created variable in conf.py using the html_context dictionary

{% extends "!layout.html" %}

{%- block content %}
{{ navBar() }}
{% if pagename == "index" and show_banner %}
  <div class="container-fluid text-center">
    <h1>{{ banner_title }}</h1>
    <img src="{{ pathto('_static/' + banner_image, 1) }}">
  </div>
{% endif %}
<div class="container">
  <div class="row">
    {%- block sidebar1 %}{{ bsidebar() }}{% endblock %}
    <div class="{{ bs_span_prefix }}{{ bs_content_width }} content">
      {% block body %}{% endblock %}
    </div>
    {% block sidebar2 %} {# possible location for sidebar #} {% endblock %}
  </div>
</div>
{%- endblock %}

@himito
Copy link
Author

himito commented Nov 1, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants