feature: Meta Tag in flet like html
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
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.titlein your route-change handler and callpage.update(). On the web it updates the browser tab title. - Site-wide meta tags (description,
og:*,twitter:*, verification tags, etc.): ship your ownindex.htmlin your assets directory.flet run --web,ft.run(main, view=ft.AppView.WEB_BROWSER, assets_dir="assets")orflet publish: Flet servesassets/index.htmlinstead of its built-in one. Start from Flet's defaultindex.htmlso its placeholders (such as<!-- fletAppConfig -->) are kept.flet build web: theassetsfolder is copied overbuild/webafter the build, so copy the generatedbuild/web/index.htmltoassets/index.html, add your tags and rebuild.project.descriptioninpyproject.tomlalready 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.