# Elisp Breadcrumbs

DevFeed: [Elisp Breadcrumbs](<https://devfeed.tech/articles/elisp-breadcrumbs-34425.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2011/07/elisp-breadcrumbs/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2011-07-14T16:44:00Z

Content type: tutorial

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [Development](<https://devfeed.tech/topics/development.md>), [Website](<https://devfeed.tech/topics/website.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [code](<https://devfeed.tech/tags/code.md>), [dev](<https://devfeed.tech/tags/dev.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [project](<https://devfeed.tech/tags/project.md>), [website](<https://devfeed.tech/tags/website.md>)

## AI overview

This tutorial presents Emacs Lisp code for adding breadcrumbs to a Muse-generated website. The breadcrumbs link an article to its local and parent indexes and to the site's root page, and the code inserts them into the generated HTML.

## Source excerpt

A breadcrumb is a navigation aid. I just added one to this website, so that it gets easier to browse from any article to its local and parents indexes and back to /dev/dim, the root webpage of this site. As it was not that much work to implement, here's the whole of it: ;;; ;;; Breadcrumb support ;;; (defun tapoueh-breadcrumb-to-current-page () "Return a list of (name . link) from the index root page to current one" (let* ((current (muse-current-file)) (cwd (file-name-directory current)) (project (muse-project-of-file current)) (root (muse-style-element :path (caddr project))) (path (tapoueh-path-to-root)) (dirs (split-string (file-relative-name current root) "/"))) ;; ("blog" "2011" "07" "13-back-from-char11.muse") (append (list (cons "/dev/dim" (concat path "index.html"))) (loop for p in (butlast dirs) collect (cons p (format "%s%s/index.html" path p)) do (setq path (concat path p "/")))))) (defun tapoueh-insert-breadcrumb-div () "The real HTML inserting" (insert "<div id=\"breadcrumb\">") (loop for (name . link) in (tapoueh-breadcrumb-to-current-page) do (insert (format "<a href=%s>%s</a>" link name) " / ")) (insert "</div>\n")) (defun tapoueh-insert-breadcrumb () "Must run with current buffer being a muse article" (save-excursion (beginning-of-buffer) (when (tapoueh-extract-directive "author" (muse-current-file)) (re-search-forward "<body>" nil t) ; find where the article content is (re-search-forward "<h2>" nil t) ; that's the title line (beginning-of-line) (open-line 1) (tapoueh-insert-breadcrumb-div) (re-search-forward "<h2>" nil t 2) ; that's the TAG line (beginning-of-line) (open-line 1) (tapoueh-insert-breadcrumb-div)))) This code is now called in the :after function of my Muse project style, and it gets the work done.