Remove index.html from Hexo URL? - ejs

In Hexo how do I remove the index.html bit from page.path?
My code:
<link rel="canonical" href="<%= config.url %>/<%= page.path %><% } %>">
Rendered HTML:
<link rel="canonical" href="http://yoursite.com/about/index.html">
Thank you in advance

This request is on the roadmap for Hexo 4.0. It hasn't been implemented yet (at the time of writing this answer).
In the issue above, sapegin gave a workaround using a custom helper:
hexo.extend.helper.register('page_url', function(path, options) {
return this.url_for(path, options).replace(/index\.html$/, '');
});
If you place this helper in a file like scripts/helpers.js, you can then use it in your posts and pages:
<%= page_url(page.path) %>
It's not as nice as a built-in variable, but it works.

Because pages need to place in subdirectory. It's looks like this:
source
_posts
...
about
index.md
That's all. No need any helpers here.
P.S. You also can see live example and source code with this.

Related

How to access the front matter in a docusaurus website?

I am working on a docusaurus based website which has front matter available in the following format.
---
id: introduction
title: Welcome to Rowy
slug: /
---
I am integrating Cusdis (an open source commment system plugin) and I wish to consume the page id and title front matter. How can I do that?
I tried using a variety of methods to consume the front matter, for example {props. } for the following code.
<head>
<script async defer src="https://cusdis.com/js/cusdis.es.js"></script>
</head>
<div id="cusdis"
data-host="https://cusdis.com"
data-app-id="**********************************"
data-page-id= {props.id}
data-page-url="http://docs.rowy.io"
data-page-title= {props.title}
data-theme="auto"
></div>
Here, {props.id} is being read as the Introduction which is the value of {props.id}, which is weird. Would love some guidance.
Frontmatter can be accessed via the following within a Markdown page, so I'm assuming it could work in your plugin.
<div>
{frontMatter.fieldname}
</div>

Mathjax in Github pages

I have started a new project in Github and as I will need to collaborate with people, I wanted to start a decent documentation. I would like to use Github Pages for this task, but the documentation will need to include many equations, as for instance https://wec-sim.github.io/WEC-Sim/theory.html.
I have read on-line on numerous posts that Mathjax provides a good tool to read equations on browsers and has been linked to Github pages. However, although I tried to follow many different strategies, I have not been able to get my Page to show any equations yet.
You can find my project at https://github.com/enricoande/uuv and the corresponding page at https://enricoande.github.io/uuv/. The page is built from https://github.com/enricoande/uuv/blob/master/docs/README.md.
Initially, I was not able to display equations at all, but could see the text in the Page. Now, I am not even able to see the page. This has happened after adding the file https://github.com/enricoande/uuv/blob/master/docs/_layouts/page.html which reads
<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
Is it possible that the reason why I can no longer see my page is that Mathjax is too slow (I have found comments on this regard on-line)? Otherwise, have you got suggestions on what I could do to fix the Page to display the equations?
As you can see I am a beginner with Github pages and html.
Any suggestion is well appreciated as I am now utterly stuck. Thank you for the help!
If I open the referenced JS file at https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML, I see
console.warn('WARNING: cdn.mathjax.org has been retired. Check https://www.mathjax.org/cdn-shutting-down/ for migration tips.')
So check https://www.mathjax.org/cdn-shutting-down/ for detailed migration tips.
Example solution
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?...">
</script>
If you open the HTML source of your page, you'll notice that it contains nothing but the script tag.
This is expected since your page template is not actually a template -- for that it would have to contain {{ content }} or similar liquid templating tags so that it can pull content from the actual page.
For example, https://github.com/jekyll/jekyll/blob/master/docs/_layouts/page.html has
---
layout: default
---
<section class="standalone">
<div class="grid">
<div class="unit whole">
<article>
<h1>{{ page.title }}</h1>
{{ content }}
</article>
</div>
<div class="clear"></div>
</div>
</section>
You will then have to create an index.html file in your docs folder that starts with
---
layout: page
---
so that it pulls in the page template (and the script tag).
Try installing jekyll and generating the default site to evaluate good defaults; see the docs for more information on that. Usually, a script tag appears in a head, header or footer template.

Add2Any print preview instead of print

I use AddToAny plugin to a Joomla website. I need to replace the code so I can "preview page" instead of "print" (ctrl+p).
I found AddToAny files into /plugins/content/addtoany, but I see no code for print service code
There is no code in the plugin for links generation, unless if you're talking about the css class to add a specific link (see below).
All the links are generated via the AddToAny's js: http://static.addtoany.com/menu/page.js
As you probably already know, all the rendering is generated with classes (powered by the js file above): https://www.addtoany.com/buttons/customize/standalone_services
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_google_plus"></a>
<a class="a2a_button_pinterest"></a>
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
</div>
<script type="text/javascript" src="//static.addtoany.com/menu/page.js"></script>
This means the links themselves are not "generated" in the plugin, so your solutions are whether try to override the plugin via the MVC override plugin or develop your own solution.

using .php with .css or some thing better?

I have a log in page for my web site. The log in file is "index.php" this will be the first page you come to when comming to my site. The rest of my site is HTML with a style.css file providing the look for my site. Now my questions is how do I get my index.php file too look like the rest of my web site?
Right now when you come to mydomain.com/index.php it is just a white page with a log in and password box. I would like my log in page to look like the rest of my web site. Can some one please refer me as how to do this?
I have other .php files that would also need to be linked with the .css such as register.php and so forth. thanks guys.
If there is a different/better method of doing what I need please feel free to chime in, I'm all ears at this point I've been trying to do this for 2 days.
Like you would do in every other html page you will have to link the file the same way.
I guess that you have already seen that in every php file there is html code?
Just stay out of the php brackets
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body
<?php
"php code in here"
?>
</body>
</html>
If you don't find the usual html markup somewhere search for a include function in the php file.
Maybe the html header is in other php file and it is being called from there.
They would be included like this
include '_header.php';
You can use the CSS file, similar to how you use it in your HTML files. You can either post the CSS tag below your PHP code, or you can use an echo "cssTagHere"; call within your PHP code.
If you're using a login page, though, are you maintaining that security with the rest of your site by using PHP on your other pages?

does anybody know how to link to a stylesheet in layout.phtml - zend framework?

I'm setting up my master layout.phtml file , but i can't seem to link to an external css i've tried the normal link href ect but does not work i'm following the beginner' guide to ZF in the manaul is has the following:
<base href="/" />
<link rel = "stylesheet" type="text/css" href ="/css/master.css" />
the manual also suggests putting these assets in the public folder which i have done. but does not work ?
I have also looked on the net and tried a some headlink and bootstrap stuff as a beginner it was a bit over my head !
Has anyone got a simple answer ??
many thanks
I usually do as follows in layout.phtml:
<?php
$this->headLink()->appendStylesheet($this->baseUrl('/css/master.css'));
echo $this->headLink();
?>
What is the map hierarchy? on the page you're working on, is in that folder a folder css and in that folder the master.css?