Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Hugo and js. Add Title to header on scroll

On my static Hugo website I need the word "Critique" in the bottom of my sticky header on List.html page of the critique section and on the single.html of the section before scrolling. But on scrolling I would like to add the article title only on the single.html page but not on the list.html page. This is the logic I need somewhere in my partials/page-title.html

    {{ $page-scroll := "no-scroll" }}
    <script>
        $(window).on("scroll", function () {
        if ($(this).scrollTop() > 150) {
            ${page-scroll} = "scroll";
        }}
    </script>
    
    <section class="page-title">
      <div class="container">
        <div class="row">
          <div class="col-10">
          {{ if eq .Section "critique" }} <h3>Critique {{ if eq $page-scroll "scroll" }} / {{ .Title}} {{end}}</h3> {{ end }}
         </div>
        </div>
  </div>
</section>

Unfortunately the script doesn't change $page-scroll variable. What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hugo variables are referenced like this:

{{ $page-scroll }}

However, you are looking for something like this:

<script>
    $(window).on("scroll", function () {
    if ($(this).scrollTop() > 150) {
        document.getElementById('showme').style.display = 'inline';
    }}
</script>

{{ if eq .Section "critique" }} 
  <h3>Critique<span id="showme" style="display: none;"> / {{ .Title}}</span></h3>
{{ end }}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!