简体   繁体   中英

How do I add a image logo to the top nav bar in Jekyll?

Just started using Jekyll to generate some basic pages and wanted to add a image logo to the top branding area on the navigation bar. Is there a standard way to do this without messing with the themes in Jekyll?

I don't believe it's possible to do this without at least a little customizing of the theme.

However, since you're using the default, twitter theme for Jekyll-Bootstrap, these changes should be fairly straightforward to make:

Put your logo.png in assets/themes/twitter

In your _includes/themes/twitter/default.html you'll want to add a <li> with your logo under the <ul class="nav"> element like so:

<li><a class="brand-image" href="{{ HOME_PATH }}"><img class="brand-image" src="{{ASSET_PATH}}/logo.png"/></a></li>

Next, define the brand-image class by editing assets/themes/twitter/css/style.css and add the following:

.navbar .nav > li > a.brand-image {
      padding: 4px 0px 0px 0px;
}
.navbar .nav > li > a > img.brand-image {
    -webkit-border-radius: 0px;
       -moz-border-radius: 0px;
            border-radius: 0px;

}

You'll probably have to play with the padding to get it to work just right for your image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM