How can I keep all my static content under content? - hugo

I have images, PDFs, etc. that I would like to store in one location (/content/) instead of /static/ folder for organizational reasons. Obviously, Hugo should copy this to static when I serve the webpage.
How can I do this?

Hugo can't copy things in the content/ directory to static/ by itself - you would have to use a pre-processor or post-processor like Grunt or gulp.

Related

How can I exclude an image from Hugo's public directory?

I'm using Hugo to generate a static site. I'm making use of Hugo's image functions to create different sized versions of the same image (160px, 240px, and 480px).
That's all working fine but Hugo also makes the original image available (e.g. IMG_7307.jpeg) in the public directory too. I don't want to publish the original images. How can I tell Hugo not to include them?
You should use Hugo's Build Resources options in your page's front matter. See below for an example:
---
title: Your Page's Title
_build:
publishResources: false
---
Hello, world!
Any resources in this page's bundle will not be copied into the /public directory unless their .Permalink or .RelPermalink is used.

react-create-app prod html from public folder not found for an iframe

I have a create-react-app that needs to embed an html file (along with its own JS and other files) into an iframe on one of the components. I've searched the Facebook react docs on public folder (which says it should work), various other stack overflow questions to no avail.
I added the folder ixoearth containing the external files into public folder. Folder structure
When I access it in dev mode (localhost:3000), or in prod mode from the network IP it works (eg. 192.168.1.128:63738 ). but as soon as I attempt localhost production mode it doesn't find any of the files in the public folder.
Here's my iframe URL:
iframe src
When using create-react-app you need to use a special PUBLIC_URL variable like is mentioned in the docs. This will generate the right path during the build phase so that it works in production.

CakePHP 2 path to webroot dir

How to create $this->Html->link(); to download file from Plugin webroot directory?
It's possible?
Why do you have to put the file in Plugin folder to be downloaded. This is not a good practice. Keep the file in webroot/file/name_of_folder
to get the path to webroot/ simply:
debug(WEBROOT);
Prefix with the plugin name
As mentioned in the docs, you can download plugin assets if the request url is prefixed with the plugin name (lower cased and underscored):
Simply prepend /plugin_name/ to the beginning of a request for an asset within that plugin, and it will work as if the asset were in your application’s webroot.
Note however that if the file is intended to be public it's a better idea for the asset to actually be in the webroot:
But keep in mind that handling static assets, such as images, Javascript and CSS files of plugins, through the Dispatcher is incredibly inefficient. It is strongly recommended to symlink them for production. For example like this:
ln -s app/Plugin/YourPlugin/webroot app/webroot/your_plugin
This would make it possible to access all files in a plugin's webroot directly without any rewrite or php logic being involved.

serving static file not from /static in webpy

Is there a way of serving static files (images) not from the /static folder in webpy? What I would like to do is show images that are scattered in various directories, and moving all of them to /static is really not an option. If it is not feasible in webpy, are there any other python web frameworks that would do this?
Thanks,
v923z
You can easily do it when deploying your web.app under different webserver. But if you want to set static path in web.py development server then you'll have to patch webpy's static middleware or write your own. Please check my answer to the same question here: Changing the static directory path in webpy

Setting up Smarty directories and paths

Just a general question for those of you working with the Smarty templating engine.
How are you setting up your file structure? I'd like to follow an MVC format, but I'm not sure how to include all the CSS, Javascript, etc. with the Smarty controller and templates without including these ridiculous paths.
Has anyone worked with this? Anyone have any insight?
Thanks!
Matt
mmmmmm
I would recommend another structure.
suppouse this:
document root: my_app/public_html/
my_app/
- lib
- app
- public_html/
- css/
- js/
- images/
- cache/
- compiled_templates/
- templates/
- mails/
- html/
- text/
- frontend/
- backend/
- xml/
in this was your templates are outside the document root, so.. are protected. In the other way.. anyway can go to my/site/templates/somefile.tpl
your _public_html_ folder should contain all files that users can access.
the lib folder contains the all utility classes you may use: smarty, database, etc..
the app folder contains all the bussines files, etc..etc.
anyway I think the most important point is to have the frontend and the backend in different levels.
saludos
/
/includes/smarty
/includes/class.foobar.php
/includes/class.foobar2.php
/templates/myTemplate.tpl
/templates_c/
/js/
/js/jquery/jquery.js
/css/
/css/style.css
...
works nicely
including a file, which loads all stuff:
require_once 'includes/class.foobar.php';
require_once 'smarty/Smarty.class.php';

Resources