Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugo_stats.json is missing some classes when there is somewhere an apostrophe in string #8530

Closed
divinerites opened this issue May 13, 2021 · 9 comments · Fixed by #8538 or #8546
Closed
Assignees
Milestone

Comments

@divinerites
Copy link

divinerites commented May 13, 2021

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.83.1+extended darwin/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes.

Following this thread in community I open this issue. Summary is:

If a partial has some icon define as <i class="myiconclass"></i> and is called from main index.html the classes are not written in hugo_stats.json when running hugo.

If this same partial is called from mysection/list.html then it works as expected.

[EDIT] This happens in my multilingual site with defaultContentLanguageInSubdir = false option

@bep bep added this to the v0.84 milestone May 13, 2021
@bep
Copy link
Member

bep commented May 13, 2021

If this same partial is called from mysection/list.html then it works as expected.

The collector collects classes in HTML files written to /public-- what happens if you put the exact same content in list.html as in index.html?

@divinerites
Copy link
Author

divinerites commented May 13, 2021

Not sure if I understand well what you want.

/index/html (removing some not relevant partials)

In this case : classes from feature.html are not written in json.
Same for classes in faq.html

{{ partial "header.html" . }}
{{ partial "preloader.html" . }}
{{ partial "navigation.html" . }}
{{ partial "about.html" . }}
{{ partial "faq.html" . }} ==> An other test
{{ partial "feature.html" . }} ==> The <i> classes
{{ partialCached "contact-small.html" . }}
{{ partial "footer.html" . }}

/layouts/faq/list.html

In this case : classes from feature.html are well written in json as expected.
Same for classes in faq.html

{{ partial "header.html" . }}
{{ partial "preloader.html" . }}
{{ partial "navigation.html" . }}
{{ partial "page-title" . }}
{{ partial "faq.html" . }} ==> An other test
{{ partial "feature.html" . }} ==> The <i> classes
{{ partialCached "contact-small.html" . }}
{{ partial "footer.html" . }}

@divinerites
Copy link
Author

divinerites commented May 13, 2021

Thanks for your question Bep !! Trying to narrow th pb => My descrition is not fully accurate.

I found that the problem occurs when I have an other partial called earlier in the code in /index.html.

So the problem is not index.html vs list.html. Sorry for not seing that before.

partial hero.html => no bug when I remove it

{{ if site.Params.hero.enable }}
{{ "<!-- Hero Area Image d'accueil -->" | safeHTML }}
<section class="hero-area">
    <div class="container">
        <div class="row">
            <div class="col-md-9">
                <div class="video-player">
                    {{ $path     := site.Params.hero.imageThumb }}
                    {{ partial "image_asset.html" (dict "context" . "path" $path "size" "964x642" "action" "Fill" "title" site.Params.hero.heading) }}
                </div>
            </div>
            <div class="col-md-3">
                <div class="block">
                    {{ with site.Params.hero.heading }}
                        <h1 class="seo-hack">{{ . }}</h1>
                    {{ end }}
                    {{ with site.Params.hero.description }}
                        <p>{{ . }}</p>
                    {{ end }}
                    {{ if site.Params.hero.button }}
                        <ul class="list-inline wow fadeInUp" data-wow-duration=".5s" data-wow-delay=".7s">
                            <li class="list-inline-item">
                                {{ with site.Params.hero }}
                                    {{ if .btnexterne }}
                                        <a href="{{ .btnurl | relLangURL }}" target="_blank" rel="noreferrer" class="btn btn-main" title="link">{{ .btntext }} <i class="tf-ion-android-open"></i></a>
                                    {{ else }}
                                        <a href="{{ .btnurl | relLangURL }}" class="btn btn-main" title="link">{{ .btntext }}</a>
                                    {{ end }}
                                {{ end }}
                            </li>
                        </ul>
                    {{ end }}
                </div>
            </div>
        </div>
    </div>
</section>
{{ end }}

@divinerites
Copy link
Author

THIS. DOESNT. MAKE. SENSE.

Removing the comment line {{ "<!-- Hero Area Image d'accueil -->" | safeHTML }} in this hero.html partial solves the bug.

Just that.
Is this candid camera Bep ?

@divinerites
Copy link
Author

Removing the ' in the comment solves the bug. Wohaaa.

@bep bep self-assigned this May 13, 2021
@divinerites divinerites changed the title Some classes in partial called from main index.html not written in hugo_stats.json Hugo_stats.json is missing some classes when there is somewhere an apostrophe in string May 13, 2021
@jmooring
Copy link
Member

jmooring commented May 13, 2021

Minimal reproducible example:

git clone --single-branch -b hugo-github-issue-8530 https://github.com/jmooring/hugo-testing hugo-github-issue-8530
cd hugo-github-issue-8530
hugo
cat hugo_stats.json

The hugo_stats.json file will contain the "pass" class, but the "fail" class will be missing.

See "pass" and "fail" shortcodes.

@ghost
Copy link

ghost commented May 16, 2021

@divinerites

Is this candid camera Bep ?

It's the quite tricky business of dealing with quotation marks.

@bep:
Before editing this class upside down again, please consider picking/merging pull request #8436 first, or at least parts of it. This PR deals with a number of similar issues, I currently try to evaluate whether it fixes this issue as well.

bep added a commit to bep/hugo that referenced this issue May 16, 2021
@ghost
Copy link

ghost commented May 16, 2021

Well, unfortunately, PR #8436 don't fix this issue as well. It fixes "only" fixes these four bugs with testcases there.

bep added a commit to bep/hugo that referenced this issue May 17, 2021
bep added a commit to bep/hugo that referenced this issue May 17, 2021
bep added a commit to bep/hugo that referenced this issue May 17, 2021
bep added a commit to bep/hugo that referenced this issue May 17, 2021
bep added a commit to bep/hugo that referenced this issue May 17, 2021
bep added a commit to bep/hugo that referenced this issue May 17, 2021
@bep bep closed this as completed in #8538 May 17, 2021
@bep bep reopened this May 19, 2021
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants