Make logo alt text configurable

1
closed
bmustill-rose
bmustill-rose
Posted 1 year ago

Make logo alt text configurable #3503

Contribution guidelines

I want to suggest an idea and checked that ...

  • ... to my best knowledge, my idea wouldn't break something for other users
  • ... the documentation does not mention anything about my idea
  • ... there are no open or closed issues that are related to my idea

Description

Hi,

It would be useful if it were possible to configure alt text for the logo through the configuration file. I'm currently doing it manually by modifying the generated HTML files but have only been playing with the theme for a few days so may have missed something - apologies if so.

As a side note, anecdotally, aria-label is typically spoken in preference to the value of alt, so to make this work the aria-label for the anchor either needs to be set to the desired alt text or removed completely which is the approach I'd recommend FWIW.

Thanks.

Use Cases

  • Being able to specify alt text in the configuration file instead of having to add it manually would save time
  • Making it more of a feature of the theme may encourage greater adoption
  • Alt text is an important accessibility requirement for non-decorational images

Screenshots / Mockups

No response

squidfunk
squidfunk
Created 1 year ago

Thanks for suggesting. This is actually a very good use case for theme extension, as I don't consider it a good idea to make attributes on elements configurable. It's just too fine grained. When we would make the alt text configurable, the next user would want to add a title, or a separate second logo which is only shown on mobile, etc. I think you get the gist.

The logo is hosted in its own partial, so overriding it is absolutely trivial 😊

https://github.com/squidfunk/mkdocs-material/blob/b2ecd717bdebc71b514d3eb0ace10efc497fcf98/src/partials/logo.html#L23-L29

Additionally:

  • Being able to specify alt text in the configuration file instead of having to add it manually would save time

You only pay the investment once when you override the partial.

  • Making it more of a feature of the theme may encourage greater adoption

I doubt that an alt tag would aid in adoption

  • Alt text is an important accessibility requirement for non-decorational images

The logo has an alt tag, defaulting to "logo".