Custom HTML head


#1

Dear Admins,

How can I add a custom HTML code to the head?

Example:

 <head>
 ...

 <link rel="stylesheet" type="text/css" href="external_url" />
 <script src="external_url.min.js"> 
 </script>

<script>
Custom script
</script>

</head>

#2

In 2.2 you’ll be able to use the customization feature for this.
You can override core/indico_base.html, inherit from the original one and override early_js and/or late_js. Make sure to call {{ super() }} in there so the original content of these blocks is preserved. See https://github.com/indico/indico/blob/master/indico/web/templates/indico_base.html for the structure of the template.


Unfortunately we don’t have these blocks in 2.1. But if you write your own plugin you could use the html-head template hook to inject data in the head area.


#3

Dear ThiefMaster,

Unfortunately, it does not work. The inserted code is not presented.

/opt/indico/custom/templates/core/indico_base.html:

{% extends '~indico_base.html' %}

{% block early_js %}

{{ super() }}

<link rel="stylesheet" type="text/css" href="custom.min.css" />
<script src="custom.min.js"></script>
<script>
custom
</script>


{% endblock %}

in the indico.log:
2019-02-01 21:37:33,671 DEBUG 3ade3f0401ba44dd indico.customization Customized: core/indico_base.html

1, I touched the ~/web/indico.wsgi
2, I restarted the celery
3, I upgraded the indico to the latest (2.1.7)


#4

Like I said, the block only works in 2.2 which is not released yet…

But if you have all the JS files locally you could just use the custom js feature instead of adding html there.


#5

sorry, I missed it :frowning:

Thank you for your fast replies!