I am working on a project called learning logs in the book python crash course that should be 2nd edition, chapter 18. My IDE is pycharm.
I have created a template I call index.html that inherits from a base template called base.html. Running index.html on any browser just displays the code exactly as it is and not the what the output should be. It doesn't seem to be an IDE related problem, I used the exact same code using sublime text and notepad. What am I not doing right.
base.html
<p>
➊ Learning Log
</p>
➋ {% block content %}{% endblock content %}
index.html
➊ {% extends "learning_logs/base.html" %}
➋ {% block content %}
<p>Learning Log helps you keep track of your learning, for any topic
you're
learning about.</p>
➌ {% endblock content %}
tried using different IDEs, copy pasting the code from the book.
Related
{% extends 'base.html' %}
{% block content %}
my index file starts like this but it's not extending base.html it's just showing me my index.html with what I pasted up there as text in my index.html. Im so confused..
I just tried searching solutions but i dont see what else i could change. I'm new to this stuff so only thing it could be is something with the routing but I'm just launching these without app.yaml or main.py files
I am trying to setup my site (https://ashishrao7.github.io/ashish-rao/) using github pages and so far the experience has been good except for one small thing. An additional tile appears on the home page and the source of the problem is that the css file assets/css/main.css gets indexed as a page for some reason. I am using a modified version of the jekyll theme named Forty https://andrewbanchich.gitlab.io/forty-jekyll-theme/
I could temporarily solve this problem locally by going to '_site' folder (not included in the repo because it gets built) and deleted the code associated with the that unwanted tile. However, it would reappear every-time I rebuild my site and I was looking for a more permanent solution. Upon some debugging, I figured out that this unnecessarily indexed tile was getting detected as a page for some reason in _includes\tiles.html:
{% for page in site.pages limit:site.tiles-count %}
However, I am stuck now I don't know how to fix this issue. The annoying tile is shown in the figure below.
Upon clicking, it takes the viewer to the page https://ashishrao7.github.io/ashish-rao/assets/css/main.css which is not what I intended. Here is the link to the github repo that hosts the site https://github.com/ashishrao7/ashish-rao.
I can definitely reproduce, but it looks to be the expected behaviour of site.pages.
site.pages – A list of all Pages.
Source: https://jekyllrb.com/docs/variables/#site-variables
This said, on the same page listing all the site variables, there is an alternative that you could use:
site.html_files – A subset of site.static_files listing those which end in .html.
So you just need to change your loop from
{% for page in site.pages %}
{{ page.title }}
{% endfor %}
to
{% for page in site.html_files %}
{{ page.title }}
{% endfor %}
I am using Jekyll to make a personal website. I downloaded a Bootstrap template and started changing details around. I changed the config.yml file as well as the index.html file.
When I write bundle exec jekyll serve into the command line, the server starts running and I can see a demo of what my website will look like once it is being hosted online.
The changes I made to the config.yml file persist, but those I made to the index.html file do not. When I look at the index.html file, every single change I made is reverted back to the original. It's almost like the index.html gets regenerated to a default version whenever I run the server.
The same thing happens when I try to change the default image files within the project. The new images that I placed in the img folder get deleted and the old ones that I removed get regenerated.
I googled around but found no helpful answer (deleting my browser cache does not solve the issue). Anyone know what's going on?
Edit: I should add a piece of information that may be the cause of this issue. I have two index.html files in my website. One of them is in the root folder and it simply redirects to "layout: default". The other one is in the _site folder. The latter is the one I tried to change to no avail.
Default file:
<!DOCTYPE html>
<html>
{% include head.html %}
<body id="page-top" class="index">
{% include nav.html %}
{% include header.html %}
{% include portfolio_grid.html %}
{% include about.html %}
{% if site.contact == "static" %}
{% include contact_static.html %}
{% elsif site.contact == "disqus" %}
{% include contact_disqus.html %}
{% else %}
{% include contact.html %}
{% endif %}
{% include footer.html %}
{% include modals.html %}
{% include js.html %}
</body>
</html>
Every time jekyll serve or jekyll build is executed, the default behaviour is to regenerate all your site into the _site folder.
To make changes to your index.html root file, you need to edit the one outside the _site folder (probably named /index.md or /index.html) because the content of_site` are built in each run.
I'm creating a web application using Django in IntelliJ. My HTML file wants an image but somehow my development server will not show the image at all. If I'm directly opening the HTML file and not using the server, I can see the image. I somehow feel it's an IntelliJ issue. I marked the folder as resources root and tried a bunch of things: creating an images folder at the root level and marking the folder as resources root, putting the image in same folder as HTML file; nothing works.
HTML Code:
{% extends 'base.html' %}
{% block head %}
<title>Page</title>
{% endblock %}
{% block body %}
<br><br><br>
<center><img src="1.png" height="200" width="200"></center>
{% endblock %}
Project Structure
You should also put the img file inside your static fold. Check this for detail:https://docs.djangoproject.com/en/1.11/howto/static-files/#configuring-static-files
As far as I gather, Jekyll parses an included page through the templating stage if and only if it finds a YAML header / front matter. Otherwise it just copies it. Is there a way to force Jekyll to parse an included file without a front matter?
The rule of thumb is that Jekyll will not parse files without front matter.
However... there is a work-around. You can create an index.html file in the _includes directory without front matter. The Liquid in this file will be interpreted by Jekyll. You can render this include anywhere using:
{% include index.html %}
This solution is perfect for rendering HTML pages within a Jekyll context (without having the front matter requirement), especially when you want to reuse them. This could be useful for rendering a preview AND showing the code in a code block on another page. The include could be written in a layout file or in an index.md file.
Note that the included filename can be a variable (https://jekyllrb.com/docs/includes/):
{% if page.my_variable %}
{% include {{ page.my_variable }} %}
{% endif %}
Also note that if you want to show Liquid examples in this code, you should use:
{% raw %} ... Liquid example ... {% endraw %}
If you want a solution work-around for your specific situation, you should share your repository and explain your use case.