Visitar URL original
block extracopyright not overriden · Issue #2508 · squidfunk/mkdocs-material · GitHub
Skip to content

block extracopyright not overriden #2508

Closed

Description

@EdouardThiel

Hello,

extracopyright doesnt work for me:

  • I have added custom_dir: overrides after the material theme in mkdocs.yml
  • also added an overrides/main.html file:
{% extends "base.html" %}

{% block htmltitle %}
<title>This is a title</title>
{% endblock %}

{% block extracopyright %}
This is my extra copyright
{% endblock %}

The title works, but the extracopyright outputs nothing; that's because in base.html the block footer includes partials/footer.html and currently, includes doesn't override blocks.

Is it possible to correct the templates with a variable or a macro instead of a block extracopyright? or a special way to import footer.html ?

For instance replace the block in footer.html by

        Made with
        <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
          Material for MkDocs
        </a>
        {{ extracopyright }}

or even better, define extracopyright in the config (like copyright) and so in footer.hml it would be

        Made with
        <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
          Material for MkDocs
        </a>
        {{ config.extracopyright }}

without having to write an overrides/main.html file.

Activity

  1. squidfunk commented on Mar 29, 2021

    @squidfunk
    Owner

    Thanks for reporting!

    But it outputs nothing, because the block footer includes "partials/footer.html" and currently, includes doesn't override blocks.

    That's correct, that's a limitation of Jinja we completely forgot about 😅 I don't think we should add another variable in mkdocs.yml, because we already have copyright and adding extracopyright is kind of confusing. I think the best thing we can do is remove the template block, because currently it has no use. You can override footer.html, if you wish to.

  2. EdouardThiel commented on Mar 29, 2021

    @EdouardThiel
    ContributorAuthor

    But it would be very simple to replace it by

            Made with
            <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
              Material for MkDocs
            </a>
            {{ extracopyright }}

    and then, in overrides/main.html, write

    {% extends "base.html" %}
    
    {% block htmltitle %}
    <title>This is a title</title>
    {% endblock %}
    
    {% set extracopyright %}
    This is my extra copyright
    {% endset %}

    It works nice, and the main advantage is that I don't have to broke the footer logic, nor froze the footer.html with a modifed copy!

  3. XhmikosR commented on Apr 4, 2021

    @XhmikosR
    Contributor

    @squidfunk I also hit this in pi-hole/docs#491 and I agree that overriding a block is a lot easier and less work to keep in sync than the whole template, especially for people not too familiar with the syntax :)

  4. squidfunk commented on Apr 10, 2021

    @squidfunk
    Owner

    I merged both PRs. This will be available with the next release.

  5. added
    bugIssue reports a bug
    resolvedIssue is resolved, yet unreleased if open
    on Apr 10, 2021
  6. squidfunk commented on Apr 10, 2021

    @squidfunk
    Owner

    Released as part of 7.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions