I decided to switch the Bootstrap docs site (https://getbootstrap.com/) to Hugo. I know this isn’t going to be an easy process, but I believe the pros justify the time I’ll spend.
Many things are currently broken; I can’t use the highlight shortcode in index.html, I’ll need to write shortcodes to replace the Jekyll plugins we use, fix aliases and probably more. But that is for after I manage to set up the structure properly.
Now, with our current structure, I’m facing an issue with some of the static files. Specifically the dist/ folder which we need in the publishdir but I can’t move it into the static folder because many things will break since people link to the dist files from all over the web.
How could I overcome this issue without plugging in gulp or something similar?
Ah, OK, people link directly to the dist folder on GitHub … I assume you could set staticDir to “…/dist”; which would probably solve one problem and create another. If you create a theme you will get two static dirs…
Again, I’m having a hard time understanding what you write. The static folder is included by default, so I’m sure you must mean something completely different.
The second option isn’t really an option for me since I don’t have any Go knowledge.
So, I’ll try to hook up Gulp and see how it goes.
I already miss the ability to use shortcodes and highlighting in html, although it’s just for the home page so I can probably work around it by using partials.
You can have HTML content files with shortcodes, but that is probably not what you want in this case. Note that there is a highlight template func that can be called from partials.
And about the “multiple static” dirs; if you can describe your needs in a GitHub issue, “someone” might help you get what you want. If you need it, then probably others will also benefit from the same.
C:\Users\xmr\Desktop\bootstrap>npm run docs-compile
> bootstrap@4.0.0-beta.2 docs-compile C:\Users\xmr\Desktop\bootstrap
> cd docs/ && hugo --config config.yml
ERROR 2017/10/23 18:37:36 Failed to add template "index.html" in path "C:\\Users\\xmr\\Desktop\\bootstrap\\docs\\layouts\\index.html": template: index.html:31: unexpected "<" in command
ERROR 2017/10/23 18:37:36 Failed to add template "partials/docs-navbar.html" in path "C:\\Users\\xmr\\Desktop\\bootstrap\\docs\\layouts\\partials\\docs-navbar.html": template: partials/docs-navbar.html:3: unexpected "<" in command
ERROR 2017/10/23 18:37:36 Failed to add template "partials/docs-sidebar.html" in path "C:\\Users\\xmr\\Desktop\\bootstrap\\docs\\layouts\\partials\\docs-sidebar.html": template: partials/docs-sidebar.html:4: unexpected "<" in command
ERROR 2017/10/23 18:37:36 index.html : template: index.html:31: unexpected "<" in command
ERROR 2017/10/23 18:37:36 partials/docs-navbar.html : template: partials/docs-navbar.html:3: unexpected "<" in command
ERROR 2017/10/23 18:37:36 partials/docs-sidebar.html : template: partials/docs-sidebar.html:4: unexpected "<" in command
Started building sites ...
ERROR 2017/10/23 18:37:37 Error while rendering "page": template: _default/docs.html:13:7: executing "_default/docs.html" at <partial "docs-navbar...>: error calling partial: template: "partials/docs-navbar.html" is an incomplete or empty template
npm ERR! code ELIFECYCLE
npm ERR! errno 4294967295
npm ERR! bootstrap@4.0.0-beta.2 docs-compile: `cd docs/ && hugo --config config.yml`
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the bootstrap@4.0.0-beta.2 docs-compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xmr\AppData\Roaming\npm-cache\_logs\2017-10-23T15_37_37_269Z-debug.log
docs-sidebar.html isn’t converted yet, but the above errors come from using a shortcode in html. For example:
To use shortcode in HTML it must live below /content. All files below /layouts are templates (i.e. Go templates if the suffix is HTML). But I’m guessing you would not want to go that route.
You need to concatenate the multiline with printf. It looks a little ugly, but it works. If you split it into multiple assignments it doesn’t look too bad.
But in general, you will be more effective if you take this discussion in the PR. Showing a working solution is simpler than talking about it. Just mention @bep if you need me to look at it.
I have a TODO in the PR description, but here’s a few other things I was wondering.
is it possible to make variables into strings work? The use case is this {{ highlight "gem install bootstrap -v {{ .Site.Params.current_ruby_version }}" "sh" "" }}
is it possible to specify a second static dir but output it to the specified place in the publishDir? Use case, we have the dist folder which current we manually copy it into the static/foo/dist folder
I noticed that if a data file’s name has - then Hugo cannot process it. Not sure if you can do something about it since I see it’s a limitation of Go https://github.com/gohugoio/hugo/issues/1474. That being said, is it possible to work around this? Like using it in a range: {{ range $i, $release := .Site.Data.docs-versions }}
I also had to change our versions data file to explicitly use strings because otherwise 4.0 was being shows as 4. Every other version showed up fine though. Not sure if it’s a bug or a limitation.
Now the only thing I haven’t a solution yet, without creating multiple shortcodes is how to loop through a data file within a generic shortcode. Example of what we did before:
{% capture example %}
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Well done!</h4>
<p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
<hr>
<p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
</div>
{% endcapture %}
{% include example.html content=example %}
This is our content folder, so I’d need to create shortcodes for each case like the above, right?
Thanks in advance for any help, looking forward to finishing this branch
Everything is possible, but it is not on my current task list. I’m sure others will chime in with a good workaround.
Not to my knowledge.
Use:
{{ (index .Site.Data "docs-versions") }}
Depends on the data format used (they differ in their number handling), but for versions I think you can avoid a lot of head aches by storing them as strings.