------------------------------------------------------------------------------- Generating a Directory Listing Not all web servers can generate directory listings (Static Sites), or if they do (like apache, and nginx) the directory listing has been disabled at the system level, and users are not allowed to re-enable. Directory Listings Best Practices... https://community.wd.com/t/58397 Which lists points such as... * breadcrumb path for the current directory, link to all parent directories * custom header and footer for each * folder sizes * thumbnail previews (images, videos, pdf's) * directory tree * select and download multiple files So far I have NOT found a simple but practical directory index file generator, without all the extranious features of templating found in full SSG's. Here are some ways of generating directory listings... ------------------------------------------------------------------------------- Apache If enabled Apache can generate quite good directory listings... Complete with headers footers, file type icons, and individual file comments. I have yet to find any altuernative that provides the equivelent generation, and would love to see something that can generate this outside Apache. I have actually used a local apache webserver to generate index files which I then include in the file upload to a static web site. In fact you're probably using that sight right now, (the "Tower of Computational Sorcery")! --- To enable (if allowed), you need to create a ".htaccess" file (make sure it is readable) with the options line... Options Indexes However to go further you may also want to set the following options to generate a 'fancy' listing, with out excess 'size/date' information. IndexOptions FancyIndexing IconWidth=12 NameWidth=* IndexOptions SuppressColumnSorting SuppressLastModified SuppressSize You can specifically remove files from the directory listing using... IndexIgnore .* *.gif do_not_list_this_file.txt NOTE: 'IndexIgnore' will automatically ignore files or directories that are not readable or accessible. But does not prevent the files from being accessed, for example the 'GIF' images in the above ignore are not listed but can still be used by other pages, including in the directory listing itself (see below). The FancyIndexing also has 'filetype' icons which normally comes from the server's "/icon" aliases image directory, and which are normally defined in the apache "autoindex.conf" file. Of course a remote static site will not have these, so you will want to set them to images you do upload. For example the default settings to use the "text.gif" image for text files are.. # By mime filetype AddIconByType (TXT,/icons/text.gif) text/* # By filename suffix AddIcon /icons/text.gif .txt You can use these in your ".htaccess" file too. You can also specify the mime types for specific files, or suffixes, which also helps when a client tries to download that file! For example I have... DefaultIcon /images/Symbols/scroll.gif AddIconByType (TXT,/images/Symbols/scroll.gif) text/* AddType text/plain .txt AddType text/plain .notes AddType text/plain .info AddType text/plain .txt Next you can specify the HTML you want to appear before and after the directory listing (which can also specify document colours, and CSS settings for the directory.. HeaderName ".header.html" ReadmeName ".footer.html" As the name implies 'ReadmeName' nowmally points to a README file, which by default is output after the directory listing. Finally Apache lets you add a text decription of the file being listed, if it is listed... AddDescription "Generating Directory Listing Indexes" dir_listings.txt As you are using a Apache ".htaccess" (if you are not generating and uploading) you may also like to improve your security by looking at this document. https://antofthy.gitlab.io/info/www/passwd_protect_101.txt This includes techniques on how to prevent some files from being served (and also remove them from directory listings) ------------------------------------------------------------------------------- Simple HTML Directory Listing Generators The Linux "tree" command can generate a simple listing with some colors... And can even do it recursivally! tree -H '.' -L 1 -T "Listing" --noreport --charset utf-8 To remove sub-directories add: --prune Only list 'zip files' use: -p '*.zip' Remove the 'tree' credits: tree ... | sed -e '/
/,+7d' It does not however let you easily ass headers and footers. A example "tree" command is given in... https://stackoverflow.com/a/46383157/701532 And a recursive script https://gist.github.com/glowinthedark/625eb4caeca12c5aa52778a3b4b0adb4 -------------------------------------------------------------------------------