Place a <link> tag in the html <head>

I know how to place meta tags in the head section. Now I want to place link tags there. How to?

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from dash import Dash, html

app = Dash(
	__name__, 
	meta_tags= [
		dict(name = 'description', content = 'Description of the site'),
		{'http-equiv':'content-language', 'content':'pt-br'}
	]
)

app.layout = [
	html.Header(
		html.Link(href='https://example.com',rel='canonical')
	),
	html.P('Some text')
]

if __name__ == '__main__':
	app.run(debug=True)

Hello @clodoaldo

Welcome to the community!

You can use the hooks system to adjust the index, you can do something similar to the steps shown under the app index, just make it for the head instead of body.

2 Likes

I managed to implement this in my app (dash=3.4.0), although I’m not sure yet it’s detected by search engines as it’s rendered dynamically, when the html head has already been generated by dash. I’ll update when tested with Google search console.

ColinMaudry/decp.info (if you don’t see results it means it’s not on main branch yet, checkthe last lines of src/pages/tableau.py on dev branch and src/utils.py for the main function)