Hi,
I would like to ask an advice regarding the following problem:
We are using Hugo (version v0.55.5/extended windows/amd64) for generating our static site https://aahi.io
I am now looking for the most elegant solution how to include a Slider Revolution (https://sliderrevoluitoinβ¦β¦) generated slider into the homepage of our Hugo site.
Ideally we would like:
- Fully separate slider-generated code from our website code
- Be able to include generated sliders at will into parts of the website via partials
- We should be able to easily update/renew the generated sliders
- We need multilingual support but we can live with per-language generated slider
One idea is to keep the generated sliders in /static/sliders and read the main slider.html of each slider with readFile and modify it with replace
Can the Hugo gurus here share some insights if and how this can be done most elegantly?
Many thanksβ¦
Have a look at Inline Shortcodes
By using these you can call a partial directly from content files.
Also by coupling the above with Page Resources and Page Bundles it is possible to write the slider code once store it in a partial and re-use it multiple times for different content.
This is an approach that meets all of the criteria that you mentioned, since you will be adding sliders with content in markdown files and not in templates.
1 Like
Hi @alexandros! Thanks for the reaction, let me clarify @LexSpeedKB question (we are from the same organisation):
There is no problem to bundle a slider as a page bundle
and call it via a short-code, the real issue we are facing is how to cleanly integrate a rather dirtily generated Slider-Revolution sliders into our clean Hugo code 
So, the Slider Revolution plugin produces something like this for each slider:
βββ NOTICE.txt
βββ assets
β βββ burger-1.png
β βββ courgette.png
β βββ dummy.png
β βββ egg-1.png
β βββ fish.png
β βββ fork-1.png
β βββ iphone_cutout.png
β βββ knife.png
β βββ leaf-1.png
β βββ onion-1.png
β βββ paprika.png
β βββ screen.jpg
β βββ transparent.png
β βββ wheat.png
βββ css
β βββ settings.css
βββ fonts
β βββ font-awesome
β β βββ css
β β β βββ font-awesome.css
β β βββ fonts
β β βββ FontAwesome.otf
β β βββ fontawesome-webfont.eot
β β βββ fontawesome-webfont.svg
β β βββ fontawesome-webfont.ttf
β β βββ fontawesome-webfont.woff
β βββ pe-icon-7-stroke
β β βββ css
β β β βββ helper.css
β β β βββ pe-icon-7-stroke.css
β β βββ fonts
β β βββ Pe-icon-7-stroke.eot
β β βββ Pe-icon-7-stroke.svg
β β βββ Pe-icon-7-stroke.ttf
β β βββ Pe-icon-7-stroke.woff
β βββ revicons
β βββ revicons.eot
β βββ revicons.svg
β βββ revicons.ttf
β βββ revicons.woff
βββ js
β βββ extensions
β β βββ revolution.extension.actions.min.js
β β βββ revolution.extension.carousel.min.js
β β βββ revolution.extension.kenburn.min.js
β β βββ revolution.extension.layeranimation.min.js
β β βββ revolution.extension.migration.min.js
β β βββ revolution.extension.navigation.min.js
β β βββ revolution.extension.parallax.min.js
β β βββ revolution.extension.slideanims.min.js
β β βββ revolution.extension.video.min.js
β βββ jquery.themepunch.enablelog.js
β βββ jquery.themepunch.revolution.min.js
β βββ jquery.themepunch.tools.min.js
βββ slider.html
We donβt want to manipulate this generated output manually so that if we need to update/modify the generated slider we donβt have to do the manual re-integration again.
So the idea is to keep these generated sliders folders somewhere separately, like e.g. /static/sliders/homepage-cs/
and have a clever Hugo code (in a short-code or partial, doesnβt matter) that would read the slider nameβs slider.html
, parse it into blocks (head/style/js/body) and re-insert the relevant blocks of the relevant layout or content page.
I guess we are looking into writing a custom pipeline if we want to do it this way?
Or can you guys see some other elegant way to do it? Any other ideas at all?
Regards,
Alex
The /static
folder just presents those files as is, on the published site; no magic. Hugo does not manipulate them. To me your challenge seems possible to script though, running some script after you update the files from the vendor.
I agree with @RickCogley either use scripts on the frontend or experiment with Local File Templates to render slider.html
with its assets from the /static/
folder. You may be able to render it by using a mix of what was already mentioned above.
But let me be honest here. Hope you donβt get it wrong but what is so special about some proprietary Wordpress plugin slider that is written with jQuery?
There are better alternatives out there that can be made to work with Hugo in a more elegant way such as the iDangerous swiper which I am using for some of my projects.
Also note that jQuery has become somewhat redundant these days and older versions have vulnerabilities.
2 Likes
@alexandros Thatβs exactly my thinking but the marketing girls just seem to love that particular Slider Revolution and we were not able to convince them otherwise this far. I will certainly check the iDangerous swiper and if you have any other alternative ideas - very welcome!
Thanks so far!
Alex
Slider Revolution code is sheer horror, but it does solve one purpose: creates beautiful responsive slides that look good on any device.
Any idea if thereβs another plugin that can be combined with iDangerous swiper to achieve fully automated slide responsiveness?
To illustrate our problem, below two versions of our home page, first with slider revolution, second with our home-made js:
https://beta.aahi.io (slider revolution)
https://beta.aahi.dev (homemade jquery)
And I do understand why our marketing prefers the first version. 
OK, perhaps we miss a duly qualified web-developer who would be able to make #2 look like #1 but we are a startup and thatβs the constraints we have at the momentβ¦
Have a good day!
Alex