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

Can a carousel item be a link? #154

Closed
mcbergsma opened this issue Apr 12, 2018 · 3 comments
Closed

Can a carousel item be a link? #154

mcbergsma opened this issue Apr 12, 2018 · 3 comments

Comments

@mcbergsma
Copy link

Is there a URL option for each carousel item? To direct the visitor to a specific page?

@GeorgeWL
Copy link
Contributor

You can try adding it as a pull for sure

@NetworkSeb
Copy link
Contributor

I've just implemented this myself after a bit of searching.

If you want to do it yourself you can do the following.

Get the carousel patrial from here:

https://github.com/devcows/hugo-universal-theme/blob/master/layouts/partials/carousel.html

and add it to your site under the partials directory (if it's not there already)

Update the caousel.html above to include an item from the markdown (I called mine .href) (As below)

{{ if default true .Site.Params.CarouselHomepage.enable }}
{{ if gt (len .Site.Data.carousel) 0 }}
<section>
    <div class="home-carousel">
        <div class="dark-mask"></div>
        <div class="container">
            <div class="homepage owl-carousel"
                data-autoplay="{{ default true .Site.Params.CarouselHomepage.auto_play }}"
                data-slide-speed="{{ default 2000 .Site.Params.CarouselHomepage.slide_speed }}"
                data-pagination-speed="{{ default 1000 .Site.Params.CarouselHomepage.pagination_speed }}">
                {{ range sort .Site.Data.carousel "weight" }}
                <div class="item">
                    {{ if .href }}
                    <a href="{{ .href }}">
                    {{ end }}
                        <div class="row">
                            <div class="col-sm-5 right">
                                <h1>{{ .title }}</h1>
                                {{ .description | safeHTML }}
                            </div>
                            <div class="col-sm-7">
                                <img class="img-responsive" src="{{ .image }}" alt="">
                            </div>
                        </div>
                    {{ if .href }}
                    </a>
                    {{ end }}
                </div>
                {{ end }}
            </div>
            <!-- /.project owl-slider -->
        </div>
    </div>
</section>
{{ end }}
{{ end }}

Then add the href item to your markdown:

weight: 1
title: "Foobar"
description: >
    HTMbLah
image: "img/blah.png"
href: "https://www.github.com"

Hope this helps!

ryanfox1985 pushed a commit that referenced this issue Feb 17, 2022
* Fix for issue #154 - .href in md file specifies link for entire carousel item.

* Fix for issue #154 - .href in md file specifies link for entire carousel item.

* Updated README.md to include new href functionality.

Updated customizable.yaml and features.yaml in exampleSite to provide examples.

* Update faq link to be correct in features.yaml
@ryanfox1985
Copy link
Contributor

closed by #343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants