JuliaBooks / Books.jl

Create books with Julia
https://huijzer.xyz/Books.jl/
Other
269 stars 18 forks source link

Duplicate online_url in config.toml? #299

Closed henry2004y closed 2 years ago

henry2004y commented 2 years ago

Hi,

I noticed that in config.toml there are two online_url and online_url_prefix:

https://github.com/JuliaBooks/Books.jl/blob/62b7708982e70066afe314aaa616abeeb536e456/docs/config.toml#L12-L14

https://github.com/JuliaBooks/Books.jl/blob/62b7708982e70066afe314aaa616abeeb536e456/docs/config.toml#L37-L38

These two variables are required to host the site with the correct urls.

rikhuijzer commented 2 years ago

Well spotted! In https://huijzer.xyz/Books.jl/sitemap.xml there is

<urlset>
<url>
<loc>https://huijzer.xyz/Books.jl/Books.jl/welcome</loc>
<lastmod>2022-08-21</lastmod>
<changefreq>monthly</changefreq>
</url>

which is wrong indeed. Would you like to make a PR? Otherwise, I'll pick it up soon

henry2004y commented 2 years ago

So this means that when there are duplicates, only the first value is read? I didn't make a PR initially because I was not sure which one to keep.

rikhuijzer commented 2 years ago

So this means that when there are duplicates, only the first value is read?

The meaning of those variables is a bit tricky indeed. The online_url_prefix is usually the only one being used because a link like /foo/bar in a browser means relative to the current domain. So, /foo/bar at https://example.com will point to https://example.com/foo/bar. That's why only online_url_prefix is needed in most cases.

However, when generating sitemap.xml and robots.txt, there is no way to figure out during the generation of the static files to which domain the site will be sent. That's why it has to be set explicitly. On second thought, I should have named it online_domain, but well it is what it is now.