Sounds like you are serving from a sub directory called markdown
?
if so you need to use baseurl - with the value of /markdown, then you prepend baseurl (or better yet relative_url) to all your urls. That or hard code the urls to include /markdown but that is not the best idea.
Fairly sure it is common for a webserver to interpret the leading slash of any url as the root of the server.
Permalinks are a little different and have to do with the form/pattern of the url. Interesting idea to put the sub directory name in it, almost seems like it could work for some pages but permalinks I think work differently for pages vs posts. Don’t try to do it with permalinks, not what that was designed for.
this may help, or google jekyll baseurl