cfenollosa / bashblog

A single Bash script to create blogs. Download, run, write, done!
1.66k stars 227 forks source link

Changing the formatting of links #141

Closed Natfan closed 7 years ago

Natfan commented 7 years ago

When I link pages within my site, I prefer to not use file extensions at the end. Is there any way to remove .html from all links within the site via the script, then rebuild every page? Or will I have to try to figure out a way with htaccess or something?

leafstrat commented 7 years ago

htaccess would be the simplest fix for your situation. The script uses .html extensions to function.

You could use another bash script. After bashblog runs, and before uploading to webhost, grab all the files in the blog and rename all the .html files, removing the extension and modifying them with sed.

sed to replace <a href="article-title.html">Article Title</a> with <a href="article-title">Article Title</a> Note there are a few replacements to be made, the all_tags.html page, all_posts.html, etc.

Natfan commented 7 years ago

That's a rather good idea, I'll give it a crack.

aggsol commented 7 years ago

How would that work with 'htaccess'?

Natfan commented 7 years ago

https://github.com/Natfan/FunLittleThings/tree/master/HTMLFixer

Here's a quick HTML linter that removes all instances of .html within <a> tags in all HTML files within the directory that you run it in.

@aggsol

leafstrat commented 7 years ago

https://stackoverflow.com/questions/28168375/how-to-write-htaccess-rewrite-rule-for-seo-friendly-url

aggsol commented 7 years ago

Thank you @Natfan @Justin-Chaschowy

Natfan commented 7 years ago

No problem man, feel free to fork and improve my code if you want :)

@aggsol