Template to sidebar title

I need help with sidebar title. I want to use a template instead of the Title name , but don’t know what to do. Need our smart community help.

 sidebar:
  title: template
  template: |
    <li>
      {% if now().hour  < 5 %} Good Night {{'\U0001F634'}}
      {% elif now().hour < 12 %} Goodmorning {{'\u2615\uFE0F'}}
      {% elif now().hour < 18 %} Good afternoon {{'\U0001F44B\U0001F3FB'}}
      {% else %} Good Evening {{'\U0001F44B\U0001F3FB'}}{% endif %}, {{user}}.
    </li>
    <li>
      Today is {{now().strftime('%A') }}, {{ now().strftime('%B') }} {% set suffix = ['st',
      'nd', 'rd'] %}{% set day = now().day %}{% set index = 3 if day // 10 == 1
      or day % 10 == 0 else (day % 10) - 1 %} {{ day~'th' if index > 2 else
      day~suffix[index] }} and it's {{ now().strftime('%-I:%M %p') }}. 
    </li>
    <li>
      Temperature   {{states('sensor.openweathermap_temperature') | int  }}°C
      {{states('sensor.openweathermap_condition') }}.
    </li>
    <li>
      There are currently
      {{states('sensor.number_of_lights_on_first_floor')}} lights on the First Floor.

    </li>    

Does the sidebar itself have a title? It needs to be in a card, surely?

Thank you for this link, but I think, I should be more specific.
It’s for this type: Lovelace: custom sidebar card - Share your Projects! / Dashboards & Frontend - Home Assistant Community (home-assistant.io).

1 Like

Ah, sorry. :woozy_face:

It’s not clear from the docs that you can use a template in the title - the type is just “string”.

You might try putting your template in a card which does accept templates and putting that at the top of the sidebar.

1 Like

I put my template in markdown card and placed before navigation buttons(can’t post my code yet, HA not accessible from my work PC). Saved without any problem, but it’s not shown this card on the sidebar

Markdown card not working , and Mushroom template card is now showing:

sidebar:
  cards:
    - type: custom:mushroom-template-card
      primary: >-
        {% if now().hour  < 5 %} Good Night {{'\U0001F634'}} {% elif now().hour

        < 12 %} Good Morning {{'\u2615\uFE0F'}} {% elif now().hour < 18 %} Good
        Afternoon  {{'\U0001F44B\U0001F3FB'}} {% else %} Good Evening

        {{'\U0001F44B\U0001F3FB'}}{% endif %} , {{user}}.
      secondary: >-
        Today is {{now().strftime('%A') }}, {{ now().strftime('%B') }} {% set
        suffix = ['st','nd', 'rd'] %}{% set day = now().day %}{% set index = 3
        if day // 10 == 1or day % 10 == 0 else (day % 10) - 1 %} {{ day~'th' if
        index > 2 else day~suffix[index] }} and it's {{ now().strftime('%-I:%M
        %p') }}.  Temperature {{states('sensor.openweathermap_temperature') |
        int  }}°C, {{states('sensor.openweathermap_condition') }}.
      icon: ''
      multiline_secondary: true
      fill_container: true
      layout: horizontal
      layout_options:
        grid_columns: 4
        grid_rows: 2