Home > Net >  How to link a website to html page in flask?
How to link a website to html page in flask?

Time:09-19

I am trying to include my GitHub page in the html file using anchor tag. But the jinja library of flask isn't allowing : which is a part of url. Is there a way to use anchor tags that reflects external existing websites?

My code is as follows:

<a id="bot" target="_blank" href="{{url_for(https://github.com/<user_name>)}}">

Thanks in advance

CodePudding user response:

url_for is for generating a URL to an end point within your Flask application.

For external URLs, just use the URL. It doesn't need calculating since external URLs are fixed (at least generally, if you need to link to different external URLs from your development/staging/production environments then you'll need logic to handle that, but not url_for).

href="https://github.com/example">
  • Related