sphinx-book-theme icon indicating copy to clipboard operation
sphinx-book-theme copied to clipboard

Custom Title/Landing Page

Open chrisjsewell opened this issue 4 years ago • 3 comments

Most books that I've seen have a front cover 😉

I think it would be great to have an (optional) front page which has a very distinctly different layout to the rest of the pages. It might even be better if (somehow) this page is not even parsed from a standard rST/Markdown page (like the current index.html), but is related to a bunch of variables, and a separate HTML template (similar to LaTeX title pages). e.g. something like you specify the variables:

title: This is my title
author: My Name
abstract: |
    This is my abstract

which get parsed into a standard or custom frontpage template:

<h1>{{ title }}</h1>
<p>by {{ author }}</p>
</br>
<p>{{ abstract }}</p>

(but obviously more fancy like https://dev.to/davidepacilio/40-free-html-landing-page-templates-3gfp)

I don't know if this needs to be something implemented upstream (like https://github.com/pandas-dev/pydata-sphinx-theme/issues/146) or we can do here.

chrisjsewell avatar Aug 07 '20 15:08 chrisjsewell

I agree something like this would be quite useful. I guess my question is whether we should special-case this at the level of HTML / templating / etc, or if we should ensure that we provide the right Markdown syntax elements + documentation to customize them so that people can accomplish this on their own.

I suspect that the latter would be easier to maintain if we were able to get where we wanted. And Sphinx already treats the master_doc page as "special" and not integrated w/ the rest of the book structure.

For certain page elements, like the title / author / etc, I think we could definitely special-case some page / site variables etc. We may want to explore that "title/author" pattern for other pages too.

btw, I like that our feature voting thing is now encouraging people to +1 their own issues 😅

choldgraf avatar Aug 07 '20 16:08 choldgraf

I looked into this a little bit more and it sounds like it should be pretty doable with a custom template + this config in Sphinx:

html_additional_pages = {
    'index': 'landingpage.html',
}

That'll render the Jinja template landingpage.html to index.html in the built site, and we have access to all the site variables etc.

I think we'd need to over-ride Jupyter Book's current behavior regarding the index.html in this case (which is to add a re-direct to the first page of the book). But other than that I bet it'd be straightforward for us to bundle a nice landing page template w/ Jupyter Book and then offer a flag to turn it on.

choldgraf avatar Sep 13 '20 16:09 choldgraf

We were just discussing this idea at quantecon and having a custom landing page would be a really useful feature such as a sphinx-frontpage extension. My search on the web landed me here :-).

cc: @AakashGfude any thoughts on how hard this would be as a simple sphinx extension?

mmcky avatar Apr 11 '22 07:04 mmcky