Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get_url() on sam_menu to get full links incl. subfolders #8

Closed
wants to merge 1 commit into from
Closed

Conversation

Lesik
Copy link

@Lesik Lesik commented Mar 26, 2020

With this PR, the sam_menu rendering template will use Zola's get_url() function in order to get a full link (including the base_url specified in config.toml). This is useful when your site destination is in a subfolder (for example http://mydomain.tld/~mysubfolder) and you don't want to prepend every link with ~mysubfolder.

(Fixes #5)

@Lesik
Copy link
Author

Lesik commented Mar 26, 2020

By the way, this PR can be tested by running zola build && python3 -m http.server and navigating to http://127.0.0.1:8000/public.

@janbaudisch
Copy link
Owner

There is a problem with the current approach, where external links are prefixed with the url as well. You can see with the github link on the example site.

@janbaudisch
Copy link
Owner

If I may add something, there is an easier way to test the site. Zola has a build-in server which even watches for changes. See zola serve.

@Lesik
Copy link
Author

Lesik commented Mar 27, 2020

@janbaudisch zola serve will serve the site from 127.0.0.1/, but this PR is a fix for sites served in subfolders like 127.0.0.1/subfolder, so zola serve will not make you observe the fix, while python webserver will.

@janbaudisch
Copy link
Owner

My bad, you are right.
The problem with prefixed absolute links still persists. If there is a solution for this, I would be happy to merge this PR.
I already thought of adding a flag to indicate whether a link is relative or not, but that seems like to much for a simple link. On the other hand, it does not seem trivial to check if a link is absolute or not.

@Lesik
Copy link
Author

Lesik commented Jul 17, 2020

I have spent a (short) while analyzing this and I didn't come up with a way to make get_url() return the right URL for both internal and external links. So this can be closed.

@Lesik Lesik closed this Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Base URL with tilde in the path
2 participants