flet icon indicating copy to clipboard operation
flet copied to clipboard

feature: Meta Tag in flet like html

Open mostafa-kessassi opened this issue 1 year ago • 1 comments

Duplicate Check

  • [x] I have searched the opened issues and there are no duplicates

Describe the requested feature

I'm working on a large website using Flet, and I want to create meta tags for all pages (paths) like the meta tags in HTML. Can you add an HTML function so we can write HTML code using Flet, or add any other way to make this easier? or we have a way for do this but i don't know it

Suggest a solution

No response

Screenshots

No response

Additional details

No response

mostafa-kessassi avatar Aug 16 '25 17:08 mostafa-kessassi

Thanks for the request! This is the same ask as #5957 (per-route title, description and Open Graph tags for SEO), which has a more detailed proposal, so I'm closing this one in favour of it. Please follow or upvote there.

What you can do today:

  • Per-route title: set page.title in your route-change handler and call page.update(). On the web it updates the browser tab title.
  • Site-wide meta tags (description, og:*, twitter:*, verification tags, etc.): ship your own index.html in your assets directory.
    • flet run --web, ft.run(main, view=ft.AppView.WEB_BROWSER, assets_dir="assets") or flet publish: Flet serves assets/index.html instead of its built-in one. Start from Flet's default index.html so its placeholders (such as <!-- fletAppConfig -->) are kept.
    • flet build web: the assets folder is copied over build/web after the build, so copy the generated build/web/index.html to assets/index.html, add your tags and rebuild.
    • project.description in pyproject.toml already fills <meta name="description">.

Note that a Flet web app is a single-page app: the same index.html (and so the same meta tags) is served for every route, and social-preview crawlers don't run JavaScript, so truly per-route tags need server-side support. That's what #5957 tracks.

ndonkoHenri avatar Nov 02 '26 20:11 ndonkoHenri