OleVik / grav-plugin-static-generator

Indexing and static generation of Page(s) for Grav.
MIT License
22 stars 1 forks source link

Error with slashes in static pages #10

Closed dimayakovlev closed 3 years ago

dimayakovlev commented 3 years ago

Plugin v.2.1.0, Grav v.1.6.27, all settings are default.

This is head of the created static version of home page /user/data/persist/static/index.html. There are no slashes in assets links, in link parameters and in canonical url.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" >
    <title>Home | Grav<title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="generator" content="GravCMS" >
    <meta name="description" content="Grav is an easy to use, yet powerful, open source flat-file CMS" >

    <link rel="icon" type="imagepng" href="userthemesquarkimagesfavicon.png" >
    <link rel="canonical" href="http:localhost" >

    <link href="assetsuserthemesquarkcss-compiledspectre.min.css" type="textcss" rel="stylesheet">
<link href="assetsuserthemesquarkcss-compiledtheme.min.css" type="textcss" rel="stylesheet">
<link href="assetsuserthemesquarkcsscustom.css" type="textcss" rel="stylesheet">
<link href="assetsuserthemesquarkcssline-awesome.min.css" type="textcss" rel="stylesheet">

    <script src="assetssystemassetsjqueryjquery-2.x.min.js"><script>

This is head of the created static version of typography page /user/data/persist/static/typography/index.html. Assets links are fine, link parameters are fine, but missing slash in canonical url after domain. Same error with canonical url on all other pages.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Typography | Grav</title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="generator" content="GravCMS" />
    <meta name="description" content="Grav is an easy to use, yet powerful, open source flat-file CMS" />

    <link rel="icon" type="image/png" href="/user/themes/quark/images/favicon.png" />
    <link rel="canonical" href="http://localhosttypography" />

    <link href="/assets/user/themes/quark/css-compiled/spectre.min.css" type="text/css" rel="stylesheet">
<link href="/assets/user/themes/quark/css-compiled/theme.min.css" type="text/css" rel="stylesheet">
<link href="/assets/user/themes/quark/css/custom.css" type="text/css" rel="stylesheet">
<link href="/assets/user/themes/quark/css/line-awesome.min.css" type="text/css" rel="stylesheet">

    <script src="/assets/system/assets/jquery/jquery-2.x.min.js"></script>
OleVik commented 3 years ago

I see what went wrong, v2.1.0 was an attempt to resolve an issue with root-prefixes. I'll have a fix shortly.

OleVik commented 3 years ago

v2.1.1 should fix this, by making the route-sanitizing more narrow and specific to media - thus also reversing the change that broke canonical URLs.

dimayakovlev commented 3 years ago

Thank you for fix! Tried updated version but canonical links incorrect anyway. {{ page.url(true, true) }} prints correct link while browse page from browser, but in static page copy there is no slash after domain name.

OleVik commented 3 years ago

That should be resolved in v2.1.2, which avoids reducing route prefixes unless they match //.

dimayakovlev commented 3 years ago

That should be resolved in v2.1.2, which avoids reducing route prefixes unless they match //.

Unfortunately, this causes a problem with scheme part of url. http://site.com will be converted to http:/site.com.

OleVik commented 3 years ago

That's odd, it shouldn't be applied to domains, only routes. I'll take a look later today.

OleVik commented 3 years ago

I went back to a simpler iteration, which in testing is closer to the intended function of the method that caused the carnage. Could you test v2.1.3?

dimayakovlev commented 3 years ago

Now canonical urls are correct.

I'm not tested early releases with absolute_urls Grav option, but now I tried it. If absolute_urls: true assets urls are incorrect:

<link rel="icon" type="image/png" href="http://localhost/user/themes/quark/images/favicon.png" />
<link rel="canonical" href="http://localhost/test/sub" />
<link href="/assets/localhost/user/plugins/form/assets/form-styles.css" type="text/css" rel="stylesheet">
<link href="/assets/localhost/user/themes/quark/css-compiled/spectre.min.css" type="text/css" rel="stylesheet">
<link href="/assets/localhost/user/themes/quark/css-compiled/theme.min.css" type="text/css" rel="stylesheet">
<link href="/assets/localhost/user/themes/quark/css/custom.css" type="text/css" rel="stylesheet">
<link href="/assets/localhost/user/themes/quark/css/line-awesome.min.css" type="text/css" rel="stylesheet">
<script src="/assets/localhost/system/assets/jquery/jquery-2.x.min.js"></script>
OleVik commented 3 years ago

The plugin has no support for absolute_urls, as that is beyond the intended use-case. The main focus for the plugin is to be able to output indices and static copies that can run domain-independent.