question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I override the <head> tag for my page?

See original GitHub issue

Hi, may I know is there a way I can add some more <script> tags inside the <head> section of the default HTML>?

<!doctype html>
  | <html lang="">
  | <head>
  | <meta charset="UTF-8">
  | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  | <title>Example</title>
  | <meta name="description" content="Foo bar">
  | <link rel="icon" type="image/png" sizes="32x32" 
 ...
  | <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/wang0618/PyWebIO-assets@v1.2.3/css/toastify.min.css">
  | <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/wang0618/PyWebIO-assets@v1.2.3/css/app.css">
  | </head>
 
<body>
  | <div class="pywebio">

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
wang0618commented, Apr 27, 2021

Sorry, a redundant linebreak was incorrectly added to the code, the correct code is:

run_js("""
$('head').append('<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxx" crossorigin="anonymous"></script>')
"""

The above code does insert the script tag to head, you need use chrome’s inspect panel to check the result rather than “View page source”: image

0reactions
Shahin-rmzcommented, Jun 1, 2021

If you want to include your javascript file, you can use the RequireJs built-in pywebio.

do you have some examples or documentation about this? I’m not very familiar with frontend and JS and need some clue. To be specific, I’m looking for a way to have templates or themes for my PuWebIO website. (does not matter Bootstrap or Boilerplate JS) Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding page head metadata from code | Learn Plasmic
Overriding page head metadata from code. You can set page-level metadata from within Plasmic Studio, and for certain frameworks including Next.js, ...
Read more >
How to override an existing meta tag in html? - Stack Overflow
1. As per this answer, I'd say that it is best do include your meta tag through server side - check if it's...
Read more >
override meta tags in masterpage at the page level - MSDN
I have a meta tag in master page and would like to override that meta tag in one of the pages. Any help...
Read more >
How to Override CSS Styles - W3docs
You must place inline styles in the <body> of the HTML document, while embedded style sheets must be placed in the <head> of...
Read more >
Is there a way to override the <title> tag specified in header.php?
First, let's change your <title> to <title><?php wp_title(' | ', true, 'right'); ?></title>. Because adding to the title string in that was ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found