-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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 TODO #28479
Comments
@bep: can you give me an example how to get the SRI hashes https://github.com/twbs/bootstrap/blob/master/config.yml#L49? The files do exist locally, we just use the cdn link for the doc snippets. Also, is there any way to get a sha384 hash instead of sha256? I know that 256 should be enough but that's what we've been using from day 1 and also we suggest on srihash.org, BootstrapCDN etc. Thanks :) |
@XhmikosR have you looked in the documentation? Note that I'm very busy at the moment (also with Hugo), so I would appreciate if you could take general Hugo questions either with 1) the docs or 2) the forum It is sha256 or sha512 (or md5). |
All right, I'll try again based on the docs alone. Have you thought about exposing sha384 too, though? I can make an issue upstream if you want. |
Unfortunately, I can't make it work, like the previous time I tried. Maybe I'm doing it wrong or it just can't work with our setup. {{ $style := resources.Get "docs/4.3/dist/css/bootstrap.css" | resources.Fingerprint }}
{{ $secureCss := $style | resources.Fingerprint "sha256" }}
<link href="{{ $secureCss.Permalink }}" integrity="{{ $secureCss.Data.Integrity }}" rel="stylesheet"> Maybe someone else has a solution, we'll see. |
Curious why you're running |
@budparr: please do :) The path to that file is relative to the So, if you do Thanks in advance for any help! |
@XhmikosR As I mentioned earlier, Hugo is looking for those files in the assets directory, yet you're pushing them to the static folder where Hugo can't read them. You're not using Hugo to process your CSS, so you'll have to read the files from that directory.
I did a very quick test on this on your repo, but you may want to adjust to your needs. |
@budparr: thanks for looking into this. Unfortunately, I cannot change the assetDir to that. We have our other assets in If I could specify the output folder for the EDIT: EDIT2: |
Hey, @XhmikosR I only saw your first edit. Did you make any progress on this? |
{{ $js := resources.Get "/docs/4.3/dist/bootstrap.js" }}
{{ $fingerprinted := $js | fingerprint }}
{{ $fingerprinted.Data.Integrity }} // The SRI string
{{ $js.RelPermalink }} // The original path, e.g. /docs/4.3/dist/bootstrap.js
{{ $fingerprinted.RelPermalink }} // /docs/4.3/dist/bootstrap.xxxxSHA256xxxx.js Note that for the above to work, these must live inside Another approach that may work better for you is to create a "headless bundle" for these (which would live inside the You would then do something ala: {{ $bundle := .Site.GetPage "myassets" }}
{{ $js := $bundle.Resources.GetMatch "**/4.3/**/bootstrap.js" }}
{{ $fingerprinted := $js | fingerprint }}
{{ $fingerprinted.Data.Integrity }} // The SRI string
{{ $js.RelPermalink }} // The original path, e.g. /docs/4.3/dist/bootstrap.js
{{ $fingerprinted.RelPermalink }} // /docs/4.3/dist/bootstrap.xxxxSHA256xxxx.js |
@budparr: no progress :/ @bep I just gave this a go and it works, sort of :) Basically I just changed the dir we copy the dist folder to
Not sure which solution is the best, this or the headless bundle approach, that's something you guys might be able to answer :) Here's my current WIP branch https://github.com/twbs/bootstrap/compare/master-xmr-hugo I'm gonna try the headless bundle approach next. |
Re sha384 -- see gohugoio/hugo#5815 -- I will get that in the (big!) release on Monday. With map files etc. in play, I think a "regular leaf bundle" will do the work, as map etc. files will just be copied to destination. |
It seems I'm having trouble creating the headless bundle, could be the content/layouts organization again. @budparr: could you try my branch and then see if you can make the headless bundle work, please? Thanks in advance! |
Hey, @XhmikosR I've been out for a conference. Happy to dig into this, though it might take me a couple of days to clear my plate first. Is the branch |
Yup, no pressure :) |
@budparr @regisphilibert maybe one of you guys could help us out with tweking the layouts/partials? :) |
@XhmikosR We're happy to help. I wasn't able to solve the issue above. Is that the issue specifically we can help with, or others? |
@budparr I have a TODO list in my OP #28479 (comment) The layouts issue is a big one and I couldn't fix it either. But if we could solve any of the above, it would help us a lot :) Also, since many people might use our docs for learning purposes, I want us to make sure we do things the right way. |
Okay. Well @regisphilibert and I will review and see what we can get done. |
Thank you guys, I really appreciate it! |
I added one more TODO:
|
Hello. I'd love to help you in the persective of checking those "to dos". I have a couple of questions: On 1.Yes, you directory structure can be completely independent of your URL structure. It's hard for me to guess what your ideal content directory structure would be (though I suppose losing On 2.Hugo is capable of producing fingerprints on resources only if they're part of the On 3.Same as above, Hugo is capable of retrieving the width and height of a given image only if given file is part of the assets directory or a Page Bundle (being a page resource. On 4.You are currently using a shortcode to load partials from within the content files's markdown. I can see that 23 times out of 24 times this shortcode is used, it is to call of the partial files prefixed He is my proposal:As it seems this behaviour is only used with the callout "shortcodes", we improve the From:
To:
The following on the other hand would remain unchanged:
On 6.No problem I think. On 7.Current the url is build from the page title which binds title and url together.
sections:
- title: Form control
page: form-control
description: Style textual inputs and textareas with support for multiple states.
- title: Select
page: select
description: Improve browser default select elements with a custom initial appearance. Then in the code we can use On 8.No problem, will be easier once 6. is implemented though. |
@regisphilibert thanks for the thorough reply and I'm so sorry for the late reply!
We'd like to keep the version in the built files, but we don't mind dropping it from the repo. The opposite, dropping the version from the source folders would simplify things a lot, because we wouldn't need to
I guess it's OK to drop this for now. We'll just keep running run the script we have before a release which updates the SRI hashes in config.yml and we commit the changes. We can of course revisit this later because it would simplify our release process :)
Currently we have the images in the static folder because we don't process them, but it's low priority so let's leave this for now :)
Your solution does seem the proper one, I don't have anything to say apart from feel free to make a PR when you have time :)
Your first suggestion seems the simplest one at this point. I didn't use Hugo's menu system because of the limitation of having to specifying everything in the frontmatter; having the menu in one place is pretty handy.
Sounds good. To sum it up: we are now preparing to release 5.0.0-alpha1, hopefully in a week or so. I'm trying to see what's left. If we could sort the layouts/folder hierarchy/docs version removal/ the other should be easier to tackle. No pressure, I really appreciate all the help you five us! And if it wasn't for @bep's work, we wouldn't be able to make the switch in the first place :) Now we just need to dot the i's and cross the t's and all this work will be live soon :) PS. You decide what issue to tackle first and just CC me on any PRs you make EDIT: forgot to mention the other thing that I'd like to finish is #29283. It works, but it needs some kind of error checking. |
@XhmikosR Is this still something to keep open or can we close? |
We still have issues that we haven't fixed. Maybe some day someone will jump in to help us with these :) |
Hello! I would like to contribute to this as it is still open. Please let me know |
maybe use Hugo Extended version for docs' CSS?This is now donebootstrap/site/layouts/_default/docs.html
Line 27 in 6335fbe
layout-{{layout}} page-{{kind}}-{{title}}{{ with .Params.body_class }} {{ . }}{{ end }}
The text was updated successfully, but these errors were encountered: