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

Add more blocks to simple base template #3405

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frederik-elwert
Copy link
Contributor

This change makes it easier to create new themes by inheriting from the simple theme. It allows customization of the whole body (while still making use of the theme’s head), or individual parts of the body like header, menu, or footer.

Pull Request Checklist

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • Updated documentation for changed code

This change makes it easier to create new themes by inheriting from the
simple theme. It allows customization of the whole body (while still
making use of the theme’s head), or individual parts of the body like
header, menu, or footer.
@justinmayer justinmayer requested a review from pauloxnet October 17, 2024 16:15
@justinmayer
Copy link
Member

Any feedback on this PR from @getpelican/reviewers?

@boxydog
Copy link
Contributor

boxydog commented Nov 3, 2024

It is traditional to have blocks for header and footer, so that seems like a decent idea. It might also be traditional to separate them out into footer.html and header.html, though I wouldn't insist.

I don't see customization of the menu, although that is mentioned in the description of this PR.

My bigger questions:

  1. Is this actually useful for someone? What is the use case?
  2. If yes, then is it possible to write a test?

@frederik-elwert
Copy link
Contributor Author

Sorry for not getting back to this earlier. Thanks for the comments.

It is traditional to have blocks for header and footer, so that seems like a decent idea. It might also be traditional to separate them out into footer.html and header.html, though I wouldn't insist.

Yes, separating them out is also a good idea, and it would make it easy to override them without even touching the base template. It would require a bit more understanding of the file layout, though, so for beginners having a single file to override might even be simpler. But I’m open to both suggestions.

A slightly related question: At the moment, the blocks are defined within the corresponding elements, i.e., there’s a <footer>, and inside that a {% block footer %}. I followed the model for head here. But the consequence is that even when overriding the footer block, one is still bound to having that footer tag around it. (It would still be possible to override the complete body block, though.) Would it make sense to switch that and have the elements within the block? (The same would apply to includes if one were to factor them out into separate files.)

I don't see customization of the menu, although that is mentioned in the description of this PR.

That’s the block nav that I was referring to.

My bigger questions:

1. Is this actually useful for someone? What is the use case?

I’m teaching SSGs with Pelican to university students, and one issue is customizing the appearance without having to write a full theme. My understanding for the existence of the simple theme was that it would be a starting point for simple customizations, which is what the docs suggest. The reason for the PR is that customization works well for the use case in the docs (mainly providing a custom CSS file), but going beyond that requires a customized copy of the base template. This PR would offer a middle way of reusing the simple theme, but allowing more customization.

And I think it would even be useful for theme authors. (I’m currently writing a simple custom theme that basically uses this mechanism.)

2. If yes, then is it possible to write a test?

I’m happy to provide a test, but I’m not really sure what the test would cover?

@boxydog
Copy link
Contributor

boxydog commented Nov 28, 2024

I’m teaching SSGs with Pelican to university students

Sounds good. What's an SSG?

I’m happy to provide a test, but I’m not really sure what the test would cover?

Literally any line of code that you changed. For example, override the footer and test that the new footer shows up.

@justinmayer
Copy link
Member

SSG is short for static site generator.

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

Successfully merging this pull request may close these issues.

3 participants