GithubHelp home page GithubHelp logo

getgrav / grav-plugin-breadcrumbs Goto Github PK

View Code? Open in Web Editor NEW
19.0 7.0 17.0 444 KB

Grav Breadcrumbs Plugin

Home Page: https://getgrav.org

License: MIT License

PHP 71.25% CSS 4.28% Twig 24.47%
grav grav-plugin breadcrumbs

grav-plugin-breadcrumbs's Introduction

Grav Breadcrumbs Plugin

Breadcrumbs

Breadcrumbs is a Grav plugin that adds links to the previous pages (following the hierarchical structure). It is particularly useful if you are using Grav to run a blog.

Installation

Installing the Breadcrumbs plugin can be done in one of two ways. Our GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.

GPM Installation (Preferred)

The simplest way to install this plugin is via the Grav Package Manager (GPM) through your system's Terminal (also called the command line). From the root of your Grav install type:

bin/gpm install breadcrumbs

This will install the Breadcrumbs plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/breadcrumbs.

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to breadcrumbs. You can find these files either on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/breadcrumbs

NOTE: This plugin is a modular component for Grav which requires Grav, the Error and Problems plugins, and a theme to be installed in order to operate.

Usage

The breadcrumbs plugin doesn't require any configuration. The moment you install it, it is ready to use.

Something you might want to do is to override the look and feel of the breadcrumbs, and with Grav it is super easy.

Copy the template file breadcrumbs.html.twig into the templates folder of your custom theme, and that is it.

/your/site/grav/user/themes/custom-theme/templates/partials/breadcrumbs.html.twig

You can now edit the override and tweak it however you prefer.

Per-page Settings

The following options are available for use in a page's YAML frontmatter, placed within the breadcrumbs mapping:

Option Default Values Description
max_depth true true or false Determines whether breadcrumbs for pages beneath the current page will be generated.

Example Per-page Settings

---
title: Some page you wrote
breadcrumbs:
  may_descend: false # Breadcrumbs will not be generated for pages underneath this one.
---

Updating

As development for the Breadcrumbs plugin continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating Breadcrumbs is easy, and can be done through Grav's GPM system, as well as manually.

GPM Update (Preferred)

The simplest way to update this plugin is via the Grav Package Manager (GPM). You can do this with this by navigating to the root directory of your Grav install using your system's Terminal (also called command line) and typing the following:

bin/gpm update breadcrumbs

This command will check your Grav install to see if your Breadcrumbs plugin is due for an update. If a newer release is found, you will be asked whether or not you wish to update. To continue, type y and hit enter. The plugin will automatically update and clear Grav's cache.

Manual Update

Manually updating Breadcrumbs is pretty simple. Here is what you will need to do to get this done:

  • Delete the your/site/user/plugins/breadcrumbs directory.
  • Download the new version of the Breadcrumbs plugin from either GitHub or GetGrav.org.
  • Unzip the zip file in your/site/user/plugins and rename the resulting folder to breadcrumbs.
  • Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing bin/grav clear-cache.

Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in user/config/plugins) will remain intact.

Configuration

Simply copy the user/plugins/breadcrumbs/breadcrumbs.yaml into user/config/plugins/breadcrumbs.yaml and make your modifications.

enabled: true
show_all: true
built_in_css: true
include_home: true
include_current: true
icon_home: ''
icon_divider_classes: 'fa fa-angle-right'
link_trailing: false

Options are pretty self explanatory.

grav-plugin-breadcrumbs's People

Contributors

b1gg avatar danielflaum avatar flaviocopes avatar flesser avatar lufog avatar mahagr avatar regaez avatar rhukster avatar robwent avatar ryanmpierson avatar w00fz avatar yankl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grav-plugin-breadcrumbs's Issues

Schema.org migration

Current schema for breadcumps is deprecated by Google

data-vocabulary.org schema is deprecated and is no longer supported by Google. Please migrate to using schema.org types.

and will be ignored after April 2020. Consider movement to Schema.org

Breadcrumbs can't be added as a modular?

Making a breadcrumbs modular with:

{% if config.plugins.breadcrumbs.enabled %}
    {% include 'partials/breadcrumbs.html.twig' %}
{% endif %}

in it doesn't work. Only fa-home icon appears. Is it intentional? Is there any way I could put working breadcrumbs between modulars which are loaded through:

{% for module in page.collection() %}
    {{ module.content }}
{% endfor %}

?

no breadcrumbs for search, archives, etc?

Maybe I am missing something as I am new to grav, but can't figure this one out. Breadcrumbs are working on all blog related pages, but pages like :

https://blog.example.com/search/query:hills

This one outputs the html with no pages included : 

<ol class="blog-breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
    </ol>
https://blog.example.com/archives_month:jul_2014
https://blog.example.com/tag:photography

These two only show the root level breadcrumb : 

<ol class="blog-breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
        	<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
            				<a itemprop="item" href="/"><span itemprop="name">Blog</span></a>	
                    	<meta itemprop="position" content="1"> 
        </li>
    </ol>

Does it not work for these types or what is going on? The pages I mentioned use their respective plugins from the grav team. I am using the blog skeleton as my default.

non-routable pages are included in breadcrumbs

I have a simple site only using pages and I have a hierarchy that nests some folders with markdown files with organizational folders without markdown files. Currently, the plugin adds these non-routable folders in the breadcrumbs list.

The simple fix, which seems to be working for me, is to check routability before adding to the hierarchy array in classes/breadcrumbs.php:

while($current && !$current->root()) {
     if($current->routable()) {
         $hierarchy[$current->url()] = $current;
     }
     $current = $current->parent();
 }

EDIT: Sorry for not making a PR. Being a bit lazy while working on the site. ;)

Is not responsive?

It doesn't seem like this is mobile friendly. Long blog names distort the layout. As an interim fix, I made a small change to the else portion of the twig to keep everything on one line and within a mobile display.

<span itemprop="name">{{ crumb.menu|truncate(15) }}</span>

This is just a bandaid, I hope someone can help with some CSS guidance.

Thanks,
J

FeatureRequest : Custom Breadcrumb Title

Hello I am Yoast Wordpress user can you please add breadcrumb title in admin please as I always use custom breadcrumb title for the page like my page name is Free Online Tutorials and Courses so I don't want this name in every page I want custom name like Tutorials only hope you understand, It will be great if you will consider adding it.

Removing the plugin causes website crash

Removing the plugin causes website frontend crashes with error

RuntimeException (400) Template "partials/breadcrumbs.html.twig" is not defined in "blog.html.twig" at line 27.

After deleting the plugin config file left in user/config/plugins, site works again.

Link trailing

As a non native speaker, can someone please explain the purpose of the setting "link trailing"?
Google was not as helpful as I hoped it would be.

Thanks in advance.

Add option to ignore current page

I think it would be nice if there could be an option to include/exclude the current page on the breadcrumb trail, similar to how you can optionally include home.

(I'll open a PR for this soon)

How to set "Home" link with custom text?

For not it takes the name from homepage title set in .md file. Is it possible to set it independent of homepage title?

For example, homepage title is "News around the world", and i want to make it just "Home".

Composer.json name : Does not match the regex pattern

[...@... breadcrumbs]$ composer update


  [Composer\Json\JsonValidationException]
  "./composer.json" does not match the expected JSON schema:
   - name : Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$

Works after changing name to getgrav/grav-plugin-breadcrumbs

Composer 2.1.14
PHP 7.4.25

Breadcrumbs doesn't recognize Flex Object path component

When I display a single Flex Object from a directory, the URL looks something like /about/careers/id:11025b4c30e0e7c93e8ab97dfd3611c7 but the bread crumbs display as About > Careers, ignoring the object component (e.g., About > Careers > My Object Title). This is using a Gantry-based theme but I don't think that's a factor.

Google Ends Rich Results for Data-Vocabulary.org Structured Data - transition to Schema.org

Hi,
many of you probably received an infotmation from google search console about error regarding Data-Vocabulary.org is being deprecated. here is the quick fix (it is really quick, spent 20min with it, not tested widely) to this to switch from Data-Vocabulary.org to the Shema.org which is supportted by Google now. It consists of 2 modifications:
1. breadcrumbs/templates/partials/breadcrumbs.html.twig

{% set crumbs = breadcrumbs.get() %}
{% set breadcrumbs_config = config.plugins.breadcrumbs %}
{% set divider = breadcrumbs_config.icon_divider_classes %}
{% set lang = "/"~html_lang %}
{% set siteurl = base_url_absolute|replace({ (lang) : ""}) %}

{% if crumbs|length > 1 or breadcrumbs_config.show_all %}
<ol id="breadcrumbs" itemscope itemtype="https://schema.org/Breadcrumblist">
    {% if breadcrumbs_config.icon_home %}
    <i class="{{ breadcrumbs_config.icon_home }}"></i>
    {% endif %}
	{% set position = 1 %}
    {% for crumb in crumbs %}
        {% if not loop.last %}
            {% if crumb.routable %}
			<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                <a href="{{ siteurl }}{{ crumb.url }}" itemprop="item"><span itemprop="name">{{ crumb.menu }}</span></a>
				<meta itemprop="position" content="{{ position }}">
			</li>
            {% else  %}
			<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                <span itemprop="name">{{ crumb.menu }}</span>
				<meta itemprop="position" content="{{ position }}">
			</li>
            {% endif %}
            <i class="{{ divider }}"></i>
        {% else %}
            {% if breadcrumbs_config.link_trailing %}
			<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                <a href="{{ siteurl }}{{ crumb.url }}" itemprop="item"><span itemprop="name">{{ crumb.menu }}</span></a>
				<meta itemprop="position" content="{{ position }}">
			</li>
            {% else %}
			<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                <span itemprop="name">{{ crumb.menu }}</span>
				<meta itemprop="position" content="{{ position }}">
			</li>
            {% endif %}
        {% endif %}
		{% set position = position + 1 %}
    {% endfor %}
</ol>
{% endif %}

2. breadcrumbs/css/breadcrumbs.css

#breadcrumbs {
    height: 3rem;
    line-height: 3rem;
    padding-left: 3rem;
}
#breadcrumbs li {
    display: inline-block;
    padding: 0 1rem;
}
#breadcrumbs ol {
    padding-left: 0;list-style:none;display:-webkit-inline-box;
}

#breadcrumbs i {
    display: inline-block;
    width: 20px;
    text-align: center;
} 

this will mage Google happy and you site will look exactly the same. You may test the structured data result here https://search.google.com/structured-data/testing-tool

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.