Reuse UI yaml

I have a markdown yaml file to display weather alerts. I would like to display this UI in two views.

Is it possible to outsource the code and reuse it in both views? I would hate to simply copy and paste the code into both views.

Is there any way to directly reference yaml files?

yes you can do that using !include

you create a (for example) weather_alerts.yaml and then use “!include weather_alerts.yaml” in the location in the original lovelace config file where you want the markdown card code to show up.


Just an illustration for a good solution provided above:


title: xxx
path: xxx
  - !include my_markdown_card.yaml
  - ...


title: yyy
path: yyy
  - !include my_markdown_card.yaml
  - ...


type: markdown
content: ...

If you need to have same card with SOME differences - consider using decluttering-card.

1 Like

Nice thanks I will try that.

I tried it out

  - title: Test
    path: test
    badges: []
      - !include ui_views/dwd.yaml

But cannot parse YAML

YAML kann nicht geparsed werden: YAMLException: unknown tag !<!include> (2898:35) 2895 | - user: be9473fcc99749889470963c43569dec 2896 | badges: [] 2897 | cards: 2898 | - !include ui_views/dwd.yaml --------------------------

Iam in the raw configuration editor

EDIT: okay i think it’s just working with yaml mode, correct?

Yaml mode only

1 Like

Yeah, sorry. I should have clarified that. I only use yaml mode and completely forget that others use storage mode.

1 Like

I switched to yaml mode and works very well. Like it more then the UI/Storage mode.

1 Like

I wholeheartedly agree. :laughing:

:smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: